如果选择了其他组合框,如何禁用comboBox(C#)

Rus*_*ari 3 c# winforms

无论如何,如果不同的组合框中有某种文本或值,则禁用组合框.我尝试了几件事似乎无法让它发挥作用.

以下是示例

组合框

Lee*_* O. 10

使用combobox1的SelectedValueChanged事件检查所选值.基于此禁用或启用combobox2.

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