Hi Mike,
I would inherit from the standard combo box and add the functionality like
in the code below:
using System;
//using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication2
{
class SearchableComboBox : ComboBox
{
private string _searchString;
public SearchableComboBox()
: base()
{
_searchString = "";
}
protected override void OnKeyPress(KeyPressEventArgs e)
{
_searchString += e.KeyChar.ToString();
this.SelectBestMatch();
}
public void ResetSearchText()
{
_searchString = "";
}
private void SelectBestMatch()
{
for(int index=0; index<this.Items.Count; index++)
{
string currentItem = (string)this.Items[index];
if (currentItem.StartsWith(_searchString))
{
this.SelectedIndex = index;
return;
}
}
}
}
}
Hope that helps
Mark R Dawson
http://www.markdawson.org
"Mike L" wrote:
> Currently, when the user presses a letter key the combo box will go to the
> first item in the collection of the combo box starting with that letter. For
> example user presses on "R", and "R2F" appears in the combo box, then the
> user presses on "H", "HIF" appears.
>
> I want the user to be able to enter 2 or 3 characters and the combo box will
> step through as the user enters the letters. For example user presses on
> "R", "R2F" appears, then the user presses "H", "RH" appears.
>