Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing button color

Status
Not open for further replies.

gergobaros

Computer
Joined
May 14, 2007
Messages
3
Location
HR
I need to change backcolor to multiple buttons(ex. 15 buttons) at once. I mean,I dont want to write the code
" button1.backcolor=color.red " 15 times!! Any ideas?
 
gergobaros,

Use the controls collection. If all your buttons begin with the same prefix (ex btnbuttonname), then it should be fairly simple to check that the control you have is a button and change the backcolor color.

SA
 
Thanks! I'll try that and report back how it went.
 
It works! This is how I wrote the code:

Buttons are named: Button1, Button2....

For i As Integer = 1 To 15
Me.Controls("Button" & i).BackColor = Color.Blue
Next i



Thanks SolidAir!!
 
gergobaros,

I have not seen it done this way, but as long as it works, its works.

SA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top