Form with StartupPosition CenterParent not centered on parent

  • Thread starter Thread starter gewe
  • Start date Start date
G

gewe

I have a form (sizeable border, shows in taskbar, nothing unusual), which
is the main form of my application (called MainForm). During an operation
progress is shown in another form, that is shown from within the main form
with: pf.Show(this);

I have set the StartupPosition of the form pf to CenterParent. When the
form shows, it is not centered on the parent.

How can I get the progress form to be shown centered on the main form?
 
If you use ShowDialog instead of Show then I think the CenterParent
will 'take'.

To have the Modalless dialog (using Show instead of ShowDialog), then
you can manually center the pf form using code like:

Form parent = this;
pf.Location = new Point(parent.Location.X + parent.Width - 3 *
pf.Width / 2, parent.Location.Y + parent.Height - 3 * pf.Height / 2);
pf.StartPosition = FormStartPosition.Manual;
pf.Show();
==================
Clay Burch
Syncfusion, Inc.
 
Back
Top