使面板可见 C# Winforms - Visual Studio

发布于 2024-12-02 19:59:05 字数 560 浏览 1 评论 0原文

我想要的是,每当我在组合框中选择某个索引时,某个面板就会变得可见。

这就是我所做的:

我创建了一个组合框 我创建了 2 个面板,

我已将属性选项卡中的 2 个面板的可见性设置为 FALSE,

但是当有人在我的 ComboBox 上选择某些内容时,我无法将它们设置为可见。

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

        }
    }

注意:我已将 2 个面板停靠在同一个 GroupBox 中。

我的代码有什么问题T_T。它说非言语成员。 :((

编辑** 我有一个新问题。每次我选择另一个选项。已设置为可见的面板不会恢复隐藏。

当我选择索引 1 时它会出现,但当我选择索引2时它也会出现oO?

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 created 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无所谓啦 2024-12-09 19:59:05

当您将 () 放在其后面时,它表示不可调用成员,因为您正在调用可见(这是一个属性)作为方法。只需将该属性设置为如下值

panel9.Visible = true;

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;

悲念泪 2024-12-09 19:59:05

它应该是 panel9.Visible = true;

在这种情况下只需执行以下操作

if(index == 1)
  {
      panel9.Visible = true;
      panel10.visible = false;
  }
else
{
      panel9.Visible = false;
      panel10.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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文