I created two forms and adding one panel on each. The button from the first form opens the second one, and the button from the second one opens the first form. The problem is that whenever i press the button to see the other form, the whole panel moves! This is the code i have for the both buttons.
private void button1_Click(object sender, EventArgs e)
{
panel1.Controls.Clear();
Form1 form = new Form1();
form.TopLevel = false;
panel1.Controls.Add(form);
form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
form.Dock = DockStyle.Fill;
form.Show();
}
I also posted a gif to see the movement they do: movement_problem
I would change the color of the whole Form like this
this.BackColor = Color.FromArgb(0, 0, 0); // this is black