I want to show a new form in the same window from where it was invoked. I know a way to show this form on PrimaryScreen or Virtual Screen by code similar to as below:
MyForm.Location = Screen.PrimaryScreen.Bounds.Location;
But i want to show it on current screen. Is there a way to find out and show it on current screen?
I have done something like this to show my form centered to the current screen:
var screen = Screen.FromPoint(Cursor.Position);
myForm.StartPosition = FormStartPosition.Manual;
myForm.Left = screen.Bounds.Left + screen.Bounds.Width / 2 - myForm.Width / 2;
myForm.Top = screen.Bounds.Top + screen.Bounds.Height / 2 - myForm.Height / 2;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With