Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Hi,

I am using combo box in WinForm.
When i'm selecting any item in combo box then selected item background color appears blue.
I want to remove this blue background color (particularly on form load, tried to set focus to other control in the form, but combo highlight not removed) yet want item to be selected.

Can someone help out on this please?
Posted
Updated 4-Dec-16 12:17pm
v4
Comments
Sergey Alexandrovich Kryukov 10-Feb-12 2:57am    
Why the tag "ADO.NET", why not "WinForms"? Well, remove one and add another.
--SA
Tejas Vaishnav 10-Feb-12 6:55am    
Remove unwanted Tag..

If the control does not allow you to set a background color for selected items as a property, then you would need to create your own owner drawn control to draw in the way you want.

There is a BackColor property, what happens when you set that ?
 
Share this answer
 
Your text in the combo box is highlighted because the focus is set to your combo box. When you select your combo box, you can direct your program to highlight a label. This works because labels do not change colors when highligted. My below code has a combo box entitled ddlSound and a label entitled lblFiveName.

Private Sub ddlSound_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddlSound.SelectedIndexChanged

If ddlSound.Text = "Sound On" Then
bSound = True
End If

If ddlSound.Text = "Sound Off" Then
bSound = False
End If

lblFiveName.Focus() 'This line removes blue focus from combo box

End Sub
 
Share this answer
 
Comments
Dave Kreskowiak 4-Dec-16 19:00pm    
You're posting an answer to a FIVE YEAR OLD question that was already answered. Your solution is also a "hack", not really a good solution.
Member 12886468 9-Dec-16 18:39pm    
I answered a FIVE YEAR old question because I just recently encountered this problem and I preferred my solution. Maybe others will prefer the extensive programming of the other solution. But regardless, it is good to have choices. Also, I had no success with the BackColor property solution.

Forums are an excellent source to learn the intricacies of programming. Mr. Kreskowiak’s comments are improper etiquette. When non-working solutions are presented, I have never previously read any insulting response like “hack”. People politely state that the solution did not work and provide more information. However, Mr. Kreskowiak believes that it is acceptable to insult a WORKING solution. He does not even bother to describe any problem with my WORKING solution. Insults discourage people from CONTRIBUTING. It is possible to properly state disagreements. Mr. Kreskowiak, your behavior is unprofessional. If you comment any further, I will no longer respond to your rude actions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900