Question

J'ai une configuration double moniteur et je veux que mon application C # pour maximiser sa fenêtre sur un écran spécifique.

Comment puis-je faire?

merci!

Était-ce utile?

La solution

Vous pouvez obtenir ce travail en déplaçant la fenêtre tout le droit chemin ou à gauche avant de maximiser. Cela devrait provoquer la fenêtre afin de maximiser à cet écran quand il ne maximise.

Autres conseils

Ceci est un code de gestion de l'écran pour une portée similaire dans un de mes projets:

        // screenId in my case is 1(first) or 2(second)
        int screenId = RegistryManager.ScreenId;
        // DualScreen management            
        if (screenId > 0)
        {
            // Have 2 screens
            if (System.Windows.Forms.Screen.AllScreens.Length == 2)
            {
                if (screenId == 1) // first
                    this.Location = new System.Drawing.Point(System.Windows.Forms.Screen.AllScreens[0].Bounds.Left, 0);
                else // second
                    this.Location = new System.Drawing.Point(System.Windows.Forms.Screen.AllScreens[1].Bounds.Left, 0);
            }
        }

Vous utilisez la classe écran pour trouver le 2ème moniteur lien

function void showOnMonitor2()
{
Screen[] sc;
sc = Screen.AllScreens;
//get all the screen width and heights
Form2 f = new Form2();
f.FormBorderStyle = FormBorderStyle.None;
f.Left = sc[1].Bounds.Width;
f.Top = sc[1].Bounds.Height;
f.StartPosition = FormStartPosition.Manual;
f.Location = sc[1].Bounds.Location;
Point p = new Point(sc[1].Bounds.Location.X, sc[1].Bounds.Location.Y);
f.Location = p;
f.WindowState = FormWindowState.Maximized;
f.Show();
}
  Public Shared Sub MoveForm(Item As Form, ScreenNumber As Integer, Optional X As Integer = 0, Optional Y As Integer = 0)
    With Screen.AllScreens(ScreenNumber).Bounds
      X -= .Left 'translate overall coordinates to screen coordinates
      Y -= .Top
    End With
    Item.Location = New System.Drawing.Point(X, Y)
  End Sub
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top