how to check if item is selected from a comboBox in C#

后端 未结 6 1954
庸人自扰
庸人自扰 2021-01-03 22:44

I\'m pretty new here.

I have a form, and want to check if the user filled it in correctly. In the form there\'s a combo box; how can I build the \"if\" statement fo

6条回答
  •  猫巷女王i
    2021-01-03 23:37

    if (combo1.SelectedIndex > -1)
    {
        // do something
    }
    

    if any item is selected selected index will be greater than -1

提交回复
热议问题