AddHandler question

usvpn

Freshman
Joined
Apr 19, 2010
Messages
45
Hi,
I create some custom button items in code.
I need to have some code for their Button_Click event and set Button.Checked = Not Button.Checked
So I use this code:

Visual Basic:
AddHandler MyAccount1Button.Click, AddressOf SubAccountButtonItem
AddHandler MyAccount2Button.Click, AddressOf SubAccountButtonItem
...

Private Sub SubAccountButtonItem(ByVal sender As Object, ByVal e As System.EventArgs)

    'How to set every Button clicked to not to clicked?
    'Button.Checked = Not Button.Checked

End Sub
 
Last edited by a moderator:
If what you are asking is how to uncheck the button that was clicked, note that the button that was actually clicked is passed as the sender argument. Cast to the appropriate control type, and you can access its properties, like so:
Code:
DirectCast(sender, Button).Text = "I've been clicked!"
 
Back
Top