8

I have a ComboBox control of DropDown type which contains items "AAA", "Aaa", "Aa+", etc.

The problem is: If I type Aaa, item "AAA" highlighted as selected, not "Aaa". I assume combobox uses FindString to find SelectedItem - so search result is equivalent to first matched item by case-insensitive string.StartsWith.

What do I need to change to override this behavior?

I need to be able to type in the ComboBox.

Is there a method in winforms I could override or some kind of property akin to WPFs IsTextSearchCaseSensitive property from sll's answer?

Roman Goyenko
  • 6,965
  • 5
  • 48
  • 81
  • 1
    Which control are you using WPF/WinForms/ASP.NET? – sll Mar 30 '12 at 22:34
  • Stack Overflow: where good questions go to die. There mustn't have been a whitepaper or RFC for anyone to quote. – Derf Skren Jun 07 '15 at 04:18
  • See answer on thread: http://stackoverflow.com/questions/25681886/prevent-autoselect-behavior-of-a-system-window-forms-combobox-c – Loathing Feb 23 '17 at 03:11

2 Answers2

3

If you are using WPF, just set IsTextSearchCaseSensitive property to true.

sll
  • 61,540
  • 22
  • 104
  • 156
-1

You can use this:

myComboBox.SelectedIndex = myComboBox.Items.IndexOf("CaseSensitiveTextHere");
Alex Pan
  • 4,341
  • 8
  • 34
  • 45
Flo
  • 31
  • 1
  • 4