Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Can I Set The Windows Form Position Manually

Tags:

c#

I am developing Desktop application, which loads a Form with different Texts and condition is so When i Click ok Button it shows Texts from the Form one by one

it is working perfectly but the Problem is i have more than one screen and say when i load a form on Current screen and click OK it stays at primary screen which is Ok ,but say when i load my form and drag it to next screen and click ok its comes back again to Primary Screen But i want it to stay on another Screen ...where i drag it into

here is line of code which loads my form

if(Form1.ShowDialog(this) == DialogResult.OK)

// at this line every time i click ok it shows the form but in Primary Screen so is there any solutions i can control the position i mean new position where i grag it into.

like image 949
DeveloperSD Avatar asked Jul 14 '15 08:07

DeveloperSD


1 Answers

You can use Form.Location property and Form.StartPosition :

// Set the start position of the form to the manual.

form1.StartPosition = FormStartPosition.Manual;

form1.Location = new Point(100, 100);

More information :

https://msdn.microsoft.com/en-us/library/aa984420(v=vs.71).aspx

https://msdn.microsoft.com/en-us/library/system.windows.forms.form.startposition(VS.80).aspx

like image 191
Fabjan Avatar answered Oct 03 '22 15:10

Fabjan