Note that there are some explanatory texts on larger screens.

plurals
  1. POComboBox AutoComplete on SubString
    primarykey
    data
    text
    <p>In one of my WinForms applications, I have a window with a ComboBox for the user to select a customer from.</p> <p>The customers in this list box are in this format : "CustomerID - CustomerName", for example "004540 - NorthWind Traders"</p> <p>The native WinForms combobox has an autocomplete feature built-in and it works well: the problem is that it only works by matching from the beginning of the string of each item of the combobox's list and not from anywhere (substring).</p> <p>What I would like my users to be able to do is to either type of the CustomerID or CustomerName, as senior users are familiar with most CustomerIDs while new recruits would benefit from being able to type the CustomerName in and get the AutoComplete anyway. That means that I actually want to look for the best match from the list where the inputted text is a substring of the ComboBox item.</p> <p>A solution often suggested for this kind of scenario is to create a hidden list box that only shows up when the user types, but I'm not happy with that as it feels like a quick hack and is not easily reusable, and may look and behave inconsistently compared to the standard ComboBox control.</p> <p>I've tried to implement this myself using the DroppedDown property to make the list appear and use SelectedIndex to set the item but the content of the combobox's textbox is reset when I do that, while I only would like the "best matching item" to be highlighted from the ComboBox lists (I need "Suggest" and not "Append", Append-mode can not be really be used with substring-matching anyway).</p> <p>I think that there must be a better way? If anyone knows of a custom / 3rd Party control doing this, I'm not against buying one either.</p> <p>Thanks.</p> <p>PS: I am programming in C# for WinForms, with .Net Framework 3.5.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload