Answers for "c# combobox return selected value"

C#
3

c# combobox selectedvalue

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    ComboBox cmb = (ComboBox)sender;
    int selectedIndex = cmb.SelectedIndex;
    int selectedValue = (int)cmb.SelectedValue;

    ComboboxItem selectedCar = (ComboboxItem)cmb.SelectedItem;
    MessageBox.Show(String.Format("Index: [{0}] CarName={1}; Value={2}", selectedIndex, selectedCar.Text, selecteVal));        
}
Posted by: Guest on November-11-2020
0

c# if combobox selected index

//detect if no selected item on ComboBox is chosen?
if( ComboBox.SelectedItem == null ) {
   // do something
}
Posted by: Guest on November-05-2020

Code answers related to "c# combobox return selected value"

C# Answers by Framework

Browse Popular Code Answers by Language