How to Disable comboBox if other comboBox is selected (C#)

后端 未结 4 1551
臣服心动
臣服心动 2021-01-03 09:21

Is there anyway to disable a combobox if a different combobox has some sort of text or value in it. I have tried a couple things and can\'t seem to get it to work.

B

4条回答
  •  梦谈多话
    2021-01-03 10:21

    Use the SelectedValueChanged event of combobox1 to check for the selected values. Disable or enable combobox2 based upon that.

    private void combobox1_SelectedValueChanged(object sender, Eventargs e)
    {
        if (combobox1.SelectedValue == myDisableValue)
            combobox2.Enabled = false;
        else
            combobox2.Enabled = true;
     }
    

提交回复
热议问题