|
|
Title | Make multiple controls share the same event handler in VB .NET |
Description | This example shows how to make multiple controls share the same event handler in VB .NET. It lists all of the controls in the event handler's Handles clause. |
Keywords | Handles, event handler, VB.NET |
Categories | Controls, VB.NET |
|
|
List all of the controls with their events in the event handler's Handles clause. In the following example, the Button1_Click event handler catches the Click events raised by controls Button1, Button2, and Button3.
|
|
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click, _
Button2.Click, Button3.Click
Dim btn As Button = DirectCast(sender, Button)
MessageBox.Show(btn.Name & " clicked", _
"Click", MessageBoxButtons.OK, _
MessageBoxIcon.Information)
End Sub
|
|
|
|
|
|