This is about ComboBox used in Winforms. I need to stop the selected item being heighlighted. I know I can get it done if I set the style of the combobox to ComboBoxStyle.DropDownList. But I'm looking for a solution where I don't have to use that. Instead, at the moment what I have done is using ComboBoxStyle.DropDown. I don't have any other option, because if I set it to DropDown, I have to deal with some other issue in my code. It's due to something else which I cannot avoid. Can someone suggest an alternative pls ?
Asked
Active
Viewed 47 times
0
-
Can you explain it more? What does it mean *Stop the selected item being heighlighted, like when combo box style is `DropDownList`* – Reza Aghaei Nov 30 '15 at 05:25
-
When I click the mouse ( left or right ), it gets highlighted in blue colour. – nidarshani fernando Nov 30 '15 at 05:29
-
Actually, mouse clicks shouldn't be allowed – nidarshani fernando Nov 30 '15 at 05:29
-
And even if you could implement it, while it will act like `DropDownList` style , why do't you use that style itself? – Reza Aghaei Nov 30 '15 at 05:32
-
This? http://stackoverflow.com/questions/25681886/prevent-autoselect-behavior-of-a-system-window-forms-combobox-c/25696213#25696213 – Loathing Nov 30 '15 at 05:47
1 Answers
0
use the following code in your form's Paint event.
private void myForm_Paint(object sender, PaintEventArgs e)
{
comboBox1.SelectionLength = 0;
}
or pass focus to another control in your combo box selected index changed event:
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
comboBox2.Focus();
}

Ehsan.Saradar
- 664
- 6
- 10