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

Backcolor of a combobox 1

Status
Not open for further replies.

SAWS

Programmer
Nov 24, 2003
6
BE
Hello,

I'am starting up my first project in VB .Net and I have a little question.

I use several fields like textboxes etc. and standard I place them disabled. I change the backcolor to white so it is clear to read. When I do this with a combobox it is still gray when it is disabled. Can I change this ?

Thanks in advance.
 
HI here is the code which u want for enabling/disabling with changing color for combobox
Regards
Nouman
Private Sub btnEnable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnable.Click
With ComboBox1
.Enabled = True
.DropDownStyle = ComboBoxStyle.DropDown
End With

End Sub

Private Sub btnDisable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisable.Click
With ComboBox1
If (.Enabled) Then

.Enabled = False
.DropDownStyle = ComboBoxStyle.DropDownList
.BackColor = Color.White
End If
End With

End Sub

Nouman Zaheer
Software Engineer
MSR
 
I tried both examples below, and it seems that when the combobox is disabled it will not change the backcolor.

cboName.BackColor = Color.FromKnownColor(KnownColor.White)

cboName.BackColor = Color.White

KJ
 
HI KJ
The above code which i sent will work the problem is that that you can only change teh back-clolor if the combobxtyle is ComboBoxStyle.DropDownList
so my code is changing it at run-time when you want to disable the combobox with white back-ground
and i am again changing it back to the ComboBoxStyle.DropDown when you want to enable it
Regards
Nouman

Nouman Zaheer
Software Engineer
MSR
 
Thanks, this solution is helpfull to my problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top