Opening Child Windows

  • Thread starter Thread starter Brian Conway
  • Start date Start date
B

Brian Conway

How you you make C# code where on a button click it will open a window at a
certain size and position on the screen? I can't find any examples other
than VB and trying to covert it to C# has not been successful.
 
Brian,

Can you show the examples in VB?

You should be able to set the Location property on the Form to indicate
where on the screen you want it to appear.

Hope this helps.
 
Brain,

Your ques is kinda not clear. Based on my understanding will try to reply
you.

1. Positioning form in the screen

Form testForm = new Form();
testForm.Left = 100; //x Pos
testForm.Top = 100; //y Pos
testForm.Show();

2. Fixing Size of the form

Form testForm = new Form();
testForm.Width = 400; //for example
testForm.Height = 500; //for example
testForm.Show();

If testForm is a MDIChildWindow, then x and y will be considered from the
parent window, not from the desktop. To positon form based on the desktop
coordinates, you have to convert the point to Screen points using
PointToScreen Function.

If testForm is not a MDIChildWindow, then it will be positioned based on
desktop co-ordinates.

Shak
 
Back
Top