Try this and keep the FormBorderStyle
of the parent form to FixedSingle
so that it's not resizable.
Say, suppose you do this on a button1_Click()
event and just declare Form f2 = new Form();
above the event. And set the start position of the child form to CenterScreen
like this:
f2.StartPosition = FormStartPosition.CenterScreen;
Using a checkBox
you can show/hide the child form easily.
Form f2 = new Form();
private void button1_Click(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.IsMdiContainer = true;
//Form f2 = new Form(); To prevent creating a new form everytime.
f2.MdiParent = this;
f2.StartPosition = FormStartPosition.CenterScreen;
if (checkBox1.Checked)
f2.Hide();
else
f2.Show();
}