Zaid Al Shattle Zaid Al Shattle - 1 year ago 90
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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download