I want to create a checkbox, If that is checked then it should display the dropdown. If not checked then it should hide the dropdown. This is how my code looks in Form.Designer.cs file.
this.comboBox2.FormattingEnabled = true;
this.comboBox2.Items.AddRange(new object[] {
"Database 1",
"Database 2",
"Database 3"});
this.comboBox2.Location = new System.Drawing.Point(165, 436);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(150, 21);
this.comboBox2.TabIndex = 13;
this.comboBox2.Text = "Database";
and My checkbox code in other file is
if (checkBox1.CheckState == CheckState.Checked)
{
}
Use Visible
this.comboBox2.Visible = false;
Which would hide comboBox2.
if (checkbox1.CheckState == CheckState.Checked)
{
this.combobox2.Visible = True;
}
else (checkbox1.CheckState == CheckState.Unchecked)
{
this.combobox2.Visible = False;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With