Form.StartPosition not working

  • Thread starter Thread starter John A Grandy
  • Start date Start date
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.
 
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
 
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
 
Back
Top