Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Administrators
Posted

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

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...