我使用在线转换器将C#代码转换为Vb.Net,但它没有正确转换事件处理程序代码。请帮助我。这是我的两个功能:
Private Sub OnPopup(sender As Object, e As PopupEventArgs)
'Piece Of Code
End Sub
Private Sub OnDraw(sender As Object, e As DrawToolTipEventArgs)
'Piece Of Code
End Sub
在线转换器将其转换如下:
Me.Popup += New PopupEventHandler(AddressOf Me.OnPopup)
Me.Draw += New DrawToolTipEventHandler(AddressOf Me.OnDraw)
请告诉我,如何在Vb.Net中解决这个问题
答案 0 :(得分:0)
对我的评论进行了解释,您正在寻找AddHandler
方法。
在你的情况下它将是
AddHandler Me.Draw, AddressOf OnDraw
AddHandler Me.Popup, AddressOf OnPopup
或者您可以使用Handles
,这是设计师使用的,如@bansi所述。
Private Sub OnPopup(sender As Object, e As PopupEventArgs) Handles Me.Popup
'Piece Of Code
End Sub
Private Sub OnDraw(sender As Object, e As DrawToolTipEventArgs) Handles Me.Draw
'Piece Of Code
End Sub