Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleMake multiple controls share the same event handler in VB .NET
DescriptionThis 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.
KeywordsHandles, event handler, VB.NET
CategoriesControls, 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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated