此vb.net
代码的c#
中的等效代码是什么?
DataFilter1.OnFilterAdded += new DataFilter.RefreshDataGridView(DataFilter1_OnFilterAdded);
我使用了转换工具,并获得了此代码:
DataFilter1.OnFilterAdded += New DataFilter.RefreshDataGridView(AddressOf DataFilter1_OnFilterAdded)
但似乎这不正确..
答案 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