2012-09-22 36 views
0
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()执行两次 并为此解决??????铌。我正在使用vb.net windows应用程序而不是web应用程序

+0

这是什么语言?习惯上把语言放在标签中。 –

+0

确保Addhandler只被调用一次。 –

回答