Combobox DropDownList and keypress

I have a dropdown that contains all TimeZone.Displayname

All of these display names are reported as:

(GMT +09: 00) Seoul, (GMT -06: 00) Central Time (US & Canada), etc.

Is there a way to get a keypress event that will look for the first letter after ")"? Right now it only recognizes the first character of the combobox line, which is "("

EDIT

Changed title because time zones are really not related to the issue.

+2


a source to share


2 answers


You will need to provide the keydown-search functionality yourself. For example, override KeyPress

and whenever a key is pressed in the list and displays the desired list item. Or, you can use a ComboBox.FindString

method to find a string, something like the following:



private void comboBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
   string findString = string.Empty;
    comboBox1.SelectedIndex = comboBox1.FindString(e.KeyChar.ToString());
   if(comboBox1.SelectedIndex > -1){e.Handled = true;}
}

      

+3


a source


I would construct your list and replace the line order with

Seoul (GMT +09:00)
Central Time (US & Canada)(GMT -06:00)
etc...

      



instead of ... have a list of two columns, so you have the original column value and revised to display. Your combobox can have "display" and "Value" ...

0


a source







All Articles