StartPosition Top Level Forms

The starting position of the child form cannot be set, even if I manually programmed it as follows:

f = new Home_Button_Forms.Home_Mandated_Organization();
f.TopLevel = false;
f.Parent = panel1;
f.WindowState = System.Windows.Forms.FormWindowState.Normal;
f.StartPosition = FormStartPosition.CenterScreen;
f.Show();

It still appears in the upper left corner of panel1 (parent form).

+4
source share
1 answer

If you want to move a form that is not at the top level to the center of its container panel, you can set the Locationforms manually:

var f = new Form2();
f.TopLevel = false;
f.Parent = this.panel1;
f.StartPosition = FormStartPosition.Manual;
f.Location = new Point((this.panel1.Width - f.Width) / 2, 
                       (this.panel1.Height - f.Height) / 2);
f.Show();
+2
source

All Articles