I want to open a form from another form with FormStartPosition.CenterParent. This works fine when having muliple screens and I run the program via Visual Studio. But when I run the EXE file it will actually not work.
var dialog = new Form();
dialog.StartPosition = FormStartPosition.CenterParent;
dialog.Show(this);
But when I run the EXE file (not via Visual Studio) and drag my form to the other screen and press the button that run the above code it will still open the form in the other screen.
I found a solution to open the forms at the same screen but there should be a way to always open a form in CenterParent in a easier way?
Here is the code snippet that will make the form always open at the same screen at least:
var dialog = new Form();
dialog.StartPosition = FormStartPosition.Manual;
var currentScreen = Screen.FromControl(this);
dialog.Location = currentScreen.Bounds.Location;
dialog.Show(this);
Any ideas?
/Rob