[VB.NET]動態新增移除事件處理常式

[VB.NET]動態新增移除事件處理常式

image

 

Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs)
    Label1.Text = Now.ToString()
End Sub

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
    AddHandler Timer1.Tick, AddressOf Timer1_Tick
End Sub

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
    RemoveHandler Timer1.Tick, AddressOf Timer1_Tick
End Sub

 

好像沒什麼機會用到,不過還是紀錄一下

AddHandler.rar


如有錯誤 歡迎指正