I would like to hide a Text Box based on the items selected in the comboBox.
This is my code:
private void Banner_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.Banner.Text.Equals("Yes"))
{
this.BannerText.Visible = true;
this.label12.Visible = true;
}
else
{
this.BannerText.Visible = false;
this.label12.Visible = false;
}
}
I don't understand what I am doing wrong. I want the BannerText
and label12
to be visible when "Yes" is selected in the combo box. This should only appear once "Yes" has been selected. Does anyone have the code for this?
Try fixing your brackets.
if (Banner.Text == "Yes")
{
BannerText.Show();
label12.Show();
}
else
{
BannerText.Hide();
label12.Hide();
}
Currently, with that else
statement floating out there by itself, your code won't compile.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.