将C#代码转换为vb.net

时间:2013-02-25 09:58:42

标签: c# asp.net vb.net

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

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

我使用了转换工具,并获得了此代码:

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

但似乎这不正确..

3 个答案:

答案 0 :(得分:3)

AddHandler DataFilter1.OnFilterAdded, AddressOf DataFilter1_OnFilterAdded

答案 1 :(得分:3)

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

AddHandler DataFilter1.OnFilterAdded, AddressOf DataFilter1_OnFilterAdded

答案 2 :(得分:2)

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

AddHandler DataFilter1.OnFilterAdded, AddressOf DataFilter1_OnFilterAdded

How to: Create Event Handlers in ASP.NET Web Pages