private void Form1_Load(object sender, EventArgs e) { panel1.Hide(); }
private void button1_Click(object sender, EventArgs e) { if (panel1.Visible) { panel1.Hide(); button1.Text = "Show panel"; } else { panel1.Show(); button1.Text = "Hide panel"; } }This code will toggle the visibility of `panel1` when `button1` is clicked. If the panel is visible, it will hide it and change the text of the button to "Show panel". If the panel is hidden, it will show it and change the text of the button to "Hide panel".