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?
This should open up the form on the active screen. Refer this for more values of StartPosition.
You can use the same technique, but instead of using the PrimaryScreen, grab the screen using Screen.FromPoint and Cursor.Position:
I have done something like this to show my form centered to the current screen:
It sounds like you aren't setting the StartPosition to Manual.
If you already have a parent form and want to open a new form on the same screen, give the ShowDialog method a reference to the parent form:
newForm.ShowDialog(this);
Without owner parameter ("this
") the new form may open on the main screen even when your parent form is on another screen.