Setting a location of screen on a dual screen monitor

RIAS
RIAS used Ask the Experts™
on
Hi,
Trying to set a working area for a dual screen .
The form opens on Screen2 rather than Screen1.
Any suggestion on how to open on the same screen as the MainForm

FrmMain : is the Main form
Code:
  With Frm2
                       
                        .StartPosition = FormStartPosition.Manual
                        workingArea = Screen.GetWorkingArea([b]FrmMain[/b])
                        .Location = New Point(workingArea.Right - Size.Width,
                          workingArea.Bottom - Size.Height)
                        .ShowDialog()                      
                    End With

Open in new window


Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Microsoft Dynamics CRM Consultant
Commented:
Hi,

Have you seen this class?
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.screen.allscreens?redirectedfrom=MSDN&view=netframework-4.7.2#System_Windows_Forms_Screen_AllScreens

Also, please go ahead and try this-

Form2.Location = Me.Location

Open in new window

Rikin ShahMicrosoft Dynamics CRM Consultant

Commented:
Also this should work-

Form2.Location = FrmMain.Location

Open in new window

AndyAinscowFreelance programmer / Consultant
Commented:
Does this work (replace your current code)
Frm2.StartPosition = FormStartPosition.CenterParent
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Author

Commented:
Thanks Andy! Will try
AndyAinscowFreelance programmer / Consultant

Commented:
ps.  To find out what happens with your current code you ought to use a breakpoint and single step to CHECK just what you get as values of the main forms location and what you are putting as values for the location of Frm2

Author

Commented:
Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial