Show WindowsForm in the center of the Screen (Dual Screen)
        Posted  
        
            by serhio
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by serhio
        
        
        
        Published on 2010-05-19T13:28:23Z
        Indexed on 
            2010/05/19
            13:30 UTC
        
        
        Read the original article
        Hit count: 223
        
I have Dual Monitors and want displaying a windows form in the center of the screen. (I have a variable MonitorId=0 or 1).
I have:
System.Windows.Forms.Screen[] allScreens=System.Windows.Forms.Screen.AllScreens;
System.Windows.Forms.Screen myScreen = allScreens[0];
int screenId = RegistryManager.ScreenId;
// DualScreen management
if (screenId > 0)
{
    // Possede 2-ieme ecran
    if (allScreens.Length == 2)
    {
        if (screenId == 1)
            myScreen = allScreens[0];
        else
            myScreen = allScreens[1];
    }
}
this.Location = new System.Drawing.Point(myScreen.Bounds.Left, 0);
this.StartPosition = FormStartPosition.CenterScreen;
        © Stack Overflow or respective owner