Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you know what event fired and which control fired it?

Status
Not open for further replies.

emaduddeen

Programmer
Mar 22, 2007
184
US
Hi Everyone,

Can you show me what code to use to find out what event fires and what control triggered the event to fire?

Thanks.

Truly,
Emad
 
Does this help?

Code:
    Private Sub Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click
        Dim c As Control = DirectCast(sender, Control)
        MessageBox.Show(c.Name)
    End Sub
 
Hi RiverGuy,

It's close but it would only handle click events.

The events could be anything such as a window re-size a button click, or anything else.

I'm hoping to trap both the control name that causes an even as well as what the actual event name is but I don't know which even that will be until it actually happens.

Truly,
Emad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top