Re: Positioning a Window

Tech-Archive recommends: Speed Up your PC by fixing your registry



For your own location:
using (Form f = new Form())
{
f.StartPosition = FormStartPosition.Manual;
f.Location = new Point(200, -20);
f.ShowDialog(); // or Show(), with or without an owner
}

To centre on the parent use StartPosition = CenterParent, lose the
Location line, and be sure to pass the parent form as the owner in
Show[Dialog](). In fact, do that anyway - it keeps things stacked
correctly ;-p

Marc

.



Relevant Pages

  • Re: Positioning a Window
    ... I had found the Location property, ... without StartPosition being set, it had no effect. ... with or without an owner ... and be sure to pass the parent form as the owner in ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Progress control in a subform
    ... the form which includes the progress control is ... I've tried using StartPosition and CenterParent. ... Where myCalcPos is just a simple calc getting the width of the owner forms ...
    (microsoft.public.dotnet.languages.vb)
  • Problem with CenterParent property
    ... appear centered in the parent form, though .NET thinks that it positioned ... the form in the center as it is used the original dimensions to calculate ... the first time and now the CenterParent is calculated properly. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: FormStartPosition.CenterParent not working??
    ... it appears the .CenterParent only operates on MDI forms -- a ... variance from the way VB6 worked. ... > I've set my forms StartPosition = FormStartPosition.CenterParent, ... > form will not center to the parent form? ...
    (microsoft.public.dotnet.languages.vb.controls)
  • Re: CenterParent Question
    ... of the parent form - and it doesn't work, so I was wondering if you ... Create a project with two forms, Form1 and Form2. ... Set Form2's StartPosition to CenterParent. ... private void button1_Click(object sender, EventArgs e) ...
    (microsoft.public.dotnet.languages.csharp)