Form with StartupPosition CenterParent not centered on parent

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?
 
C

ClayB

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top