Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop color hilighting of selected item in ComboBox?

I am using combo box in WinForm but when i was selected any item in combo box then selected item background color is 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) but item should be selected .

Can anybody help out on this...?

like image 750
Dhanapal Avatar asked Oct 20 '11 12:10

Dhanapal


2 Answers

To solve the same I have tried almost EVERYTHING:

  • setting the DropdownStyle property to DropdownList
  • this.BeginInvoke(new Action(() => { comboBox1.Select(0, 0); }));
  • combobox1.SelectionLength = 0;
  • changing comboBox.TabIndex
  • Not tried SendKeys.Send("{ESC}"); because it is not a reliable solution

Nothing helped. Maybe because I don't have text in my combobox items, only images. The only stable and working solution was to move a focus on another Label control:

    label.Focus();

You could also hide that label.

like image 110
Vadim K. Avatar answered Sep 18 '22 12:09

Vadim K.


It appears that the only way to do this is by subclassing the combobox control.

Here is an example where someone does that:

http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/e234c4a7-0cf7-4284-a072-8152f7593002/

There are probably more on the web to guide you.

like image 45
David Hall Avatar answered Sep 18 '22 12:09

David Hall