Say I had a ComboBox with these values:
Black
Red
Blue
And I have Red
currently selected. If the user then hits backspace and
You can use the following code to get the selected item of the combo box as an object:
ComboBox comboBox = new ComboBox();
// Initialize combo box
comboBox.Items.Add("Black");
comboBox.Items.Add("Red");
comboBox.Items.Add("Blue");
// Get selected one
string current = (string)comboBox.SelectedItem;
Also, the selected item can be easily removed by using one of the following lines of code:
// By item
comboBox.Items.Remove(comboBox.SelectedItem);
// By Index
comboBox.Items.RemoveAt(comboBox.SelectedIndex);