Answers for "winforms combobox get 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

Code answers related to "winforms combobox get selected value"

C# Answers by Framework

Browse Popular Code Answers by Language