Zaid Al Shattle Zaid Al Shattle - 8 months ago 49
C# Question

Whats the equivalent of C# "Click.add" for Visual Basic .net

While exporting my program from C# to manually i faced this line of code:

ctl.Click += ctl_Click;

Now this code is supposed to "add" an extra event to the event handler of the user control. (since the event of "click" wouldn't fire otherwise). However I couldn't find any equivalent events of either += or the .add for the vb. I saw some online topics about AddHandler but from what I saw it doesn't appear to be the same thing. Any suggestions?


In VB.NET you have to use AddHandler and AddressOf to attach dynamically events to control which works the same as the C# equivalent provided.

AddHandler ctl.Click, AddressOf Ctl_click

You can read more about this here on MSDN