views:

278

answers:

2

I have a dropdownlist that holds all of the TimeZone.Displayname

All of these display names come out as:

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

Is there a way to have a keypress event that would search through the first letter after the ")"? Right now it only recognizes the first character of the combobox string which is "("

EDIT

Changed title because timezones don't really have to do with the issue.

A: 

I would build your list and swap the string order to

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

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

DRapp
+1  A: 

You will have to provide the keydown-search functionality yourself. For instance, override the KeyPress, and whenever a key is pressed loop through the list and show the desired list item. Or you can use ComboBox.FindString method to find the string, something like 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;}
}
KMan