c# - Can't iterate through a combobox from a focused textbox -


i have combobox indefinite items in list, not how many items in there. have focus on textbox , want achieve change selected index of combo box when press or down. unfortunately i'm doing wrong again.

private void txtbox_keydown(object sender, keyeventargs e) {   if (e.keycode == keys.down)   {     while (combo.selectedindex <= combo.items.count)     {       if (combo.selectedindex >= combo.items.count)       {         break;       }       combo.selectedindex++     }   } } 

something that:

private void txtbox_keydown(object sender, keyeventargs e) {   // use "e.modifiers == keys.none"    // if want down arrow , not, say, alt + down; shift + down etc.   if ((e.keycode == keys.down) && (e.modifiers == keys.none)) {     // don't need default behaviour whatever     e.handled = true;     combobox combo = sender combobox;      // if selected index not last one, select next item     if (combo != null)       if (combo.selectedindex < (combo.items.count - 1))             combo.selectedindex += 1;   } } 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -