I’ve got an combobox. The cmbx had a few hundred items in it. The user must be able to type in text into the cmbx. While the user is typing in the text, the item that starts with the typed value must be selected. The user must be able to continue typing.
I tried the code below:
private void cmbGageCode_TextChanged(object sender, EventArgs e)
{
int itemsIndex = 0;
foreach (string item in cmbGageCode.Items)
{
if (item.Contains(cmbGageCode.Text))
{
cmbGageCode.SelectedIndex = itemsIndex;
}
itemsIndex++;
}
}
This results in the folowing: When a user types in the cmbx the item that contains the value is selected, and the cursor is placed at the front of the text. This means that when ever 2 characters are inserted, a item is selected and I’m unable to type in the complete value.
Does anyone have an idea on how to make this work? Maybe I need to use a different control? Or maybe I’m going about this in completely the wrong way? Please help!
Try this code.
Let me know if this is what you want.