开发者

2 panels in a GROUPBOX? WinForms

开发者 https://www.devze.com 2023-04-02 09:17 出处:网络
Is it possible to put 2 panels inside a groupbox?? Because I put 2 panels inside my groupbox and I Made them hidden.

Is it possible to put 2 panels inside a groupbox??

Because I put 2 panels inside my groupbox and I Made them hidden.

Whenever I try to make them Visible only the first panel appears.

I've tried it without being inside the groupbox and it worked fine.

Is there wrong with my code??

if (comboBox3.SelectedIndex == 1)
        {
            panel4.Visible = false;
            panel9.Visible = true;

        }

        if (com开发者_运维技巧boBox3.SelectedIndex == 2)
        {
            panel9.Visible = false;
            panel4.Visible = true;

        }


Yes you can do that.

But your code is incorrect and execute same view..it only just show only one panel when your combobox was selected. If you want to show both panels on your group box. Enable them both. Something like this:

    if (comboBox3.SelectedIndex == 1)
    {
        panel4.Visible = true; // Display Two Panels on your group box
        panel9.Visible = true;

    }

    if (comboBox3.SelectedIndex == 2)
    {
        panel9.Visible = false;   //Display only 1 Panel
        panel4.Visible = true;

    }

Regards


I know my answer may seems to weird. But i had this problem and solved it easily. I think you taken copies of your groupboxes or panels. Take a new panel from your toolbox. At least this weird (and non sense) looking solution worked great for me.

0

精彩评论

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

关注公众号