c# - KeyDown Delete from ComboBox -


i have combo box , want add key down function when delete pressed delete item in combo box , sends null value database:

    private void combobox_keydown(object sender, keyeventargs e)     {         combobox cmbx = (combobox)sender;         if (e.keycode == keys.delete)         {             cmbx.selectedindex = -1;             cmbx.selectedvalue = dbnull.value;         }     } 

but it's not working properly. suggestions

your code doesn't make sense.

cmbx.selectedindex = -1; removes selection combo box, doesn't remove selected item.

here's few different methods of removing specific elements of combobox.

// remove item index 0: cmbx.items.removeat(0); // remove selected item: cmbx.items.remove(cmbx.selecteditem); // remove "value1" item: cmbx.items.remove("value1"); 

reference: http://msdn.microsoft.com/en-us/library/19fc31ss.aspx


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -