views:

43

answers:

1

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?

+2  A: 

You can use the same technique, but instead of using the PrimaryScreen, grab the screen using Screen.FromPoint and Cursor.Position:

Screen screen = Screen.FromPoint(Cursor.Position);
MyForm.Location = screen.Bounds.Location;
Reed Copsey
I tried this. But still the new form is shown on the Primary Screen and the form size becomes a bit shorter. I tried to display if the screen where the cursor lies is a primary screen, and i get right answer. But when i assign the location, it doesn't get assigned properly.
Sam