1

vb.net此代码的等效代码是什么c#

 DataFilter1.OnFilterAdded += new DataFilter.RefreshDataGridView(DataFilter1_OnFilterAdded);

我使用了转换工具,并得到了以下代码:

DataFilter1.OnFilterAdded += New DataFilter.RefreshDataGridView(AddressOf DataFilter1_OnFilterAdded)

但这似乎是不正确的..

4

3 回答 3

3
AddHandler DataFilter1.OnFilterAdded, AddressOf DataFilter1_OnFilterAdded
于 2013-02-25T09:59:45.360 回答
3

您需要使用AddHandlerwhich 用于订阅事件(当您不使用Handles子句时):

AddHandler DataFilter1.OnFilterAdded, AddressOf DataFilter1_OnFilterAdded
于 2013-02-25T09:59:57.360 回答
2

如果要以编程方式注册事件处理程序,则必须使用AddHandler::

AddHandler DataFilter1.OnFilterAdded, AddressOf DataFilter1_OnFilterAdded

如何:在 ASP.NET 网页中创建事件处理程序

于 2013-02-25T10:00:34.437 回答