Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display app's form to display at desired monitor when debugging?

When I press F5 to debug my C# Windows form app, built with Visual Studio 2017 pro on Windows 10, the app window always displays on my main monitor, which is the middle monitor of my 3 monitors.

Is there a 'trick' to always open and display on the left-hand monitor? (I want to use middle monitor to see the source code.)

If no trick, then I must program form's x,y to persist across debug sessions.

like image 279
Doug Null Avatar asked Oct 15 '25 13:10

Doug Null


1 Answers

Try setting the form's startup location manually.

this.StartPosition = FormStartPosition.Manual;

Then you should be able to find your other monitor and apply its' location to your current form using

Screen[] screens = Screen.AllScreens;
Point location = screens[0].Bounds.Location;
this.Left = location.X;
this.Top = location.Y;

I can't confirm that this is exactly what you need since I currently am not at a computer with multiple monitors but it should be something very close to this if I'm wrong.

like image 88
Studwell Avatar answered Oct 18 '25 08:10

Studwell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!