locked
Dual Monitor issues RRS feed

  • Question

  • Hi,

    My application is running on secondary monitor, clicking a button on my application should open another form in secondary monitor, Now i have fixed this issue with the below code.

    if (Screen.AllScreens.Length > 1)
                        {                       

                            Screen s2 = Screen.AllScreens[1];
                            Rectangle r2 = s2.WorkingArea;                        
                            r2.Location = new Point(r2.Left + (screenWidth - (screenWidth / 2 + dlgWidth / 2)),
                                           r2.Top + (screenHeight - (screenHeight / 2 + dlgWidth / 2)));                       
                            this.Form.Location = r2.Location;  
                          

                        }
                        else
                        {
                            Screen s1 = Screen.AllScreens[0];
                            Rectangle r1 = s1.WorkingArea;
                            r1.Location = new Point(r1.Left + (screenWidth - (screenWidth / 2 + dlgWidth / 2)),
                                           r1.Top + (screenHeight - (screenHeight / 2 + dlgWidth / 2)));  
                            this.Form.Location = r1.Location;
                        }                 

    Above code will work only with two monitors. if we have more than 2 monitors, how to display the form in parent form?

    another problem with above code is parent app will be in secondary screen and if we open child dialog, then it is opening on the screen where parent form exists. if i drad parent screen to primary monitor and if i click on a butoon opens a form in secondary monitor.

    Please help to fix this issue

    Thursday, January 29, 2015 1:04 PM