Form.StartPosition not working


J

John A Grandy

Form.StartPosition = FormStartPosition.CenterParent;
Form.Show(this);

However , the form does not show-up centered in its parent form , but rather
somewhat to the upper-left of the screen.
 
Ad

Advertisements

A

Armin Zingler

John A Grandy said:
Form.StartPosition = FormStartPosition.CenterParent;
Form.Show(this);

However , the form does not show-up centered in its parent form , but
rather somewhat to the upper-left of the screen.
Seems to be fixed with modal Forms:
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=116937


However, still doesn't work with modeless Forms. Or it is "by
design" .........yep, it is:
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=107589


Armin
 
Ad

Advertisements

Joined
Mar 8, 2013
Messages
1
Reaction score
0
For modless form this is the solution

Set location by manually to set modless dialog (form)center of the parent form (parent)

form.StartPosition = FormStartPosition.Manual;
form.Location = new Point(parent.Location.X + (parent.Width - form.Width) / 2, parent.Location.Y + (parent.Height - form.Height) / 2);
form..Show(parent);

In dot net 4.0 - User remove control box and FormBorderStyle not sizable
along with the set location manually:
form.ControlBox = false;
form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;

problem is:
In dot net version 4.0 it is problem of cutoff the dialog from bottom (lower part of dialog not show when run)

solution is
Set Localizable property of the form as true
 

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

Similar Threads


Top