Combo Box Size Issue After All Items Are Removed

前端 未结 4 1000
梦毁少年i
梦毁少年i 2021-01-13 04:37

My application contains a ComboBox that the user can delete items from. When the program starts up it populates the ComboBox from a list of strings read in from a configurat

4条回答
  •  粉色の甜心
    2021-01-13 05:17

    To clear your combo box you can add this:

    if (versionComboBox.Items.Count == 0)
    {
        versionComboBox.Text = string.Empty;
        versionComboBox.Items.Clear();
        versionComboBox.SelectedIndex = -1;
    }
    

    Another approach is to manipulate the items in the data source and rebind the control each time (a lot less for you to worry about).

提交回复
热议问题