开发者

Make A Panel Visible C# Winforms - Visual Studio

开发者 https://www.devze.com 2023-04-03 08:43 出处:网络
What I want is that whenever I choose a certain index in my ComboBox a certain panel will become visible.

What I want is that whenever I choose a certain index in my ComboBox a certain panel will become visible.

So Here is What I've done:

I've create开发者_如何学JAVAd a ComboBox I've created 2 Panels

I've set the visibility of the 2 Panels in their properties tab to FALSE

However I was not able to set them to visible when somebody selects something on my ComboBox.

 private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (comboBox3.SelectedIndex == 0)
        {
            panel9.Visible();

        }
    }

Note: I've docked the 2 Panels in the same GroupBox.

What's wrong with my code T_T. It says non vocable member. :((

EDIT** I have a new problem. Everytime I pick another option. The panel which has been set to visible won't get back to hidden.

It will appear when I choose Index 1 but when I choose Index 2 it will also appear o.O?


It says non invocable member as you are calling visible, which is a property, as a method when you place the () after it. Just set the property to a value as below

panel9.Visible = true;


It should be panel9.Visible = true;

In that case just do something like this

if(index == 1)
  {
      panel9.Visible = true;
      panel10.visible = false;
  }
else
{
      panel9.Visible = false;
      panel10.Visible = true;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号