Hi I have 52 buttons (I know it sounds excessive), anyways on click of any of these buttons i want a procedure to be called, is there an easier way then going into the individual on click event of each button,
An addition to NoCoolHandle's post: an interesting feature of .NET is that you can have multiple handlers for the same event, such as:
Sub DoSomeStuff( agruments that match the event) handles button1.click, button2.click, button3.click etc......
Sub DoSomeOtherStuff( agruments that match the event) handles button1.click, button2.click, button3.click etc......
Both of these will execute when any of the handled buttons' click events fire.
Personally, I think this is really cool. I haven't found a situation where I actually need to do this, but it's still cool.
I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
Hey jebenson, when you have 2 subs that handle the same event, how is threading handled? are they both launched in the primary thread? if so, which one runs first?
-Rick
---------------------- If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum
You don't even have to manually add the "Handles btn1.click, btn2.click, <etc>" code for each one:
In a startup routine you can use AddHandler to bind the event for each button on the fly:
Public sub AddEventHandlers()
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is Button Then
AddHandler ctrl.click, AddressOf btn_Click
End If
Next
End Sub
Private Sub btn_Click(ByVal sender As Object, ByVal e As System.EventArgs)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.