I have created a form that should op up as dialog; its components are
initialised the way it is done in standart forms that are created in design
mode, e.g. in InitialiseComponents function ( I copied the code from Form1
;) ).

But then, one bit doesn't seem to work - I placed it into the function and
the form is displayed somewhere else and not in the center of the screen.
Here's the code bit:

this.ClientSize = new System.Drawing.Size(200, 90); //this works, just to
show that I set size first and there shouldn't be any hidden errors with
undefined size
this.Location = new
System.Drawing.Point((Screen.PrimaryScreen.Bounds.Width -
this.ClientRectangle.Width)/2,(Screen.PrimaryScreen.Bounds.Height -
this.ClientRectangle.Height)/2);

What's wrong with it?

Re: form placement: why won't this work? by Picho

Picho
Sun May 16 06:56:43 CDT 2004

Use the form StartPosition property instead.

"Sergei Shelukhin" <raven_at@home.domonet.ru> wrote in message
news:2gona1F50nsnU1@uni-berlin.de...
> I have created a form that should op up as dialog; its components are
> initialised the way it is done in standart forms that are created in
design
> mode, e.g. in InitialiseComponents function ( I copied the code from Form1
> ;) ).
>
> But then, one bit doesn't seem to work - I placed it into the function and
> the form is displayed somewhere else and not in the center of the screen.
> Here's the code bit:
>
> this.ClientSize = new System.Drawing.Size(200, 90); //this works, just to
> show that I set size first and there shouldn't be any hidden errors with
> undefined size
> this.Location = new
> System.Drawing.Point((Screen.PrimaryScreen.Bounds.Width -
> this.ClientRectangle.Width)/2,(Screen.PrimaryScreen.Bounds.Height -
> this.ClientRectangle.Height)/2);
>
> What's wrong with it?
>
>
>
>