Public Class MyNewButton
Inherits Button
Private _NewTag as string
Public Property NewTag() As String
Get
Return _NewTag
End Get
Set(ByVal value As Integer)
_NewTag = value
End Set
End Property
End Class
现在,编译此代码并获取新按钮并使用它,如下所示:
Dim NewBtn as MyNewButton
NewBtn.Text="New Button"
NewBtn.NewTag="Here New tag string" ' This is the custom property
Addhandler NewBtn.Click Addressof Btn_Click()
Private Sub Btn_Click()
msgbox("New Button")
End Sub
问题是当我单击该按钮时,方法 Btn_Click() 执行了两次并且对此的解决方案?????? NB。我正在使用 vb.net windows 应用程序而不是 web 应用程序