dev*_*ost 5 vb.net event-handling
是否可以将事件与VB8中的另一个事件挂钩?我在C#中有这个代码...
public event ShowAboutDialog = delegate {};
private void hookupEvents() {
myButton.Click += ShowAboutDialog;
}
Run Code Online (Sandbox Code Playgroud)
我试图将其转换为VB8,但无法让它工作..
Public Event ShowAboutDialog As EventHandler
Private Sub HookupEvents()
AddHandler AboutMenuItem.Click, AddressOf ShowAboutDialog
End Sub
Run Code Online (Sandbox Code Playgroud)
谢谢!
您只需在AddressOf之后传递事件处理程序例程的名称
Private Sub HookupEvents()
AddHandler AboutMenuItem.Click, AddressOf ShowAboutDialog
End Sub
Public Sub ShowAboutDialog(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
Run Code Online (Sandbox Code Playgroud)