Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock 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
May 14, 2007
3
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?
 
Replies continue below

Recommended for you

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