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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing a CommandButtons Color back to default by clicking another bu 1

Status
Not open for further replies.

thermalman

Technical User
Aug 26, 2003
89
GB
Hi,I have a program that checks whether a Keyboard key is pressed and reports that it has been pressed in a listbox and also changes a Command button's backcolor when each key is pressed. When I have tested the whole keyboard i have a Clear button that resets the backcolor back to default.

The program was originally written in VB6 and now i want to convert it to VB.Net (I am using Visual Studio 2008)

Here is the original code

Dim C As ControlFor Each C In Me.Controls
If TypeOf C Is CommandButton Then C.BackColor = vbButtonFace
Next C

I know that in .net a command button is just called button but how can i set the button backcolor back to default using .Net?

Many Thanks
 
Private Sub Clear_Click(sender As Object, e As EventArgs)
For Each c As Control In Me.Controls
If TypeOf c Is Button Then
c.BackColor = SystemColors.Control
End If
Next
End Sub


=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
C#.NET Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top