简体   繁体   中英

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

While exporting my program from C# to VB.net 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

使用AddHandler

AddHandler ctl.Click, AddressOf ctl_Click

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM