Pomocí konstrukce AddHandler:
Private Sub Label_Click(sender As Object, e As EventArgs)
MessageBox.Show(DirectCast(sender, LinkLabel).Text)
End Sub
Private Sub Form1_Load() Handles Me.Load
Dim linkLabel As New LinkLabel() With {.Text = "..."}
AddHandles linkLabel.Click, AddressOf Label_Click
' nebo
AddHandler linkLabel.Click, Sub(sender, e) MessageBox.Show(sender.ToString())
End Sub
Pro odebrání handleru se používá RemoveHandler.
|