M
Mr. B
I've an app with a bunch of Control Array of Buttons. I'll use code from my
App using 5 buttons as my example:
1) I've Dim them as a button in my Form
Dim btnUsrMonday() As Button ' User Monday Buttons
2) I've the Buttons on the Form named:
btnUsrMon1, btnUsrMon2, btnUsrMon3, btnUsrMon4, btnUsrMon5
3) I then create the Buttons Control Array in my Form
btnUsrMonday = New Button() {btnUsrMon1, btnUsrMon2, btnUsrMon3,
btnUsrMon4, btnUsrMon5}
4) Now I can control them all simply enough. Like the following will change
them all to Red with the text 'Out':
Dim i as Integer
For i = 0 To 4
btnUsrMonday(i).BackColor = Color.Red
btnUsrMonday(i).Text = "Out"
Next
What I'm looking for is a simple way to do something with ONE of them at a
time. For example, if I click on ONE of the buttons, how do I have a
sub-routine for the 'whole' array, find out which one was clicked on (ie:
btnUserMon2) and then do my colour/text change?
Obvious I can do this for each and every button. But there must be a way to
write something for the Control Array so that I can change their colour/text
when only ONE is checked (and then another, another, etc.).
I've seen a sample for Checkboxes that uses COLLECTIONS to do this... but I
can't figour out how to make it work for Buttons.
Appreciate any help.
Regards,
Bruce
App using 5 buttons as my example:
1) I've Dim them as a button in my Form
Dim btnUsrMonday() As Button ' User Monday Buttons
2) I've the Buttons on the Form named:
btnUsrMon1, btnUsrMon2, btnUsrMon3, btnUsrMon4, btnUsrMon5
3) I then create the Buttons Control Array in my Form
btnUsrMonday = New Button() {btnUsrMon1, btnUsrMon2, btnUsrMon3,
btnUsrMon4, btnUsrMon5}
4) Now I can control them all simply enough. Like the following will change
them all to Red with the text 'Out':
Dim i as Integer
For i = 0 To 4
btnUsrMonday(i).BackColor = Color.Red
btnUsrMonday(i).Text = "Out"
Next
What I'm looking for is a simple way to do something with ONE of them at a
time. For example, if I click on ONE of the buttons, how do I have a
sub-routine for the 'whole' array, find out which one was clicked on (ie:
btnUserMon2) and then do my colour/text change?
Obvious I can do this for each and every button. But there must be a way to
write something for the Control Array so that I can change their colour/text
when only ONE is checked (and then another, another, etc.).
I've seen a sample for Checkboxes that uses COLLECTIONS to do this... but I
can't figour out how to make it work for Buttons.
Appreciate any help.
Regards,
Bruce