none
Swiching panel in one form RRS feed

  • Question

  • I want to move between several panels in a form. What is it possible to show one of the panels on the form using the button every time?

    Thankful

    Wednesday, April 10, 2019 8:02 AM

All replies

  • Hi Ali_Lonbar,

    You can achieve this by setting the property "Visible" of each panel. Here is a simple demo (three panels) you can refer to:

        public Form1()
        {
            InitializeComponent();
            panel1.Visible = false;
            panel2.Visible = false;
            panel3.Visible = false;
        }
    
        int count = 0;
    
        private void btSwitch_Click(object sender, EventArgs e)
        {
            switch (count % 3)
            {
                case 0:
                    panel1.Visible = true;
                    panel2.Visible = false;
                    panel3.Visible = false;
                    break;
                case 1:
                    panel1.Visible = false;
                    panel2.Visible = true;
                    panel3.Visible = false;
                    break;
                case 2:
                    panel1.Visible = false;
                    panel2.Visible = false;
                    panel3.Visible = true;
                    break;
            }
            count++;
        }

    Result:

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, April 10, 2019 9:06 AM
    Moderator
  • Hi,

    Is your problem solved? If so, please post "Mark as answer" to the appropriate answer.So that it will help other members to find the solution quickly if they face the similar issue.

    Regards,

    Kyle


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, April 18, 2019 6:40 AM
    Moderator