witzulu Posted April 11, 2004 Posted April 11, 2004 Hi I would like to know how to retrieve the cause of a event esp. an onclick event. Say I have a sub that handles 5 different buttons onclick event, I would like to know which of the 5 buttons have been clicked Quote
Administrators PlausiblyDamp Posted April 11, 2004 Administrators Posted April 11, 2004 The sender argument will be the button that was clicked the folowing code will just display hte name of the button clicked - you could use this in a select case statement if you needed to make a decision based on this. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click, Button1.Click, Button3.Click Dim b As Button b = DirectCast(sender, Button) MessageBox.Show(b.Name) End Sub Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.