Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

winforms

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.

Below is Example

ComboBox

like image 256
Russell Saari Avatar asked Sep 03 '25 06:09

Russell Saari


1 Answers

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;
 }
like image 109
Lee O. Avatar answered Sep 04 '25 21:09

Lee O.