I try to show/hide panels in C#, but when I clicked on button1 I wanted to see panel1 but panel2 appeared. And when I cliked on button2, panel2 dissappeared. But when I cliked first on button2, panel2 didn't appear. I don't know what is wrong with my code but here it is:
public Form3()
    {
        InitializeComponent();
    }
    bool show1;
    bool show2;
    private void button1_Click(object sender, EventArgs e)
    {
        if(show1)
        {
            panel1.Visible = false;
            show1 = false;
        }
        else
        {
            panel1.Visible = true;
            show1 = true;
        }
        Application.DoEvents();
    }
    private void button2_Click(object sender, EventArgs e)
    {
        if (!show2)
        {
            panel2.Visible = true;
            show2 = true;
        }
        else
        {
            panel2.Visible = false;
            show2 = false;
        }
        Application.DoEvents();
    }
 
     
     
     
     
     
    