Form.DesktopLocation Propriété

Définition

Obtient ou définit la position du formulaire sur le bureau Windows.

public:
 property System::Drawing::Point DesktopLocation { System::Drawing::Point get(); void set(System::Drawing::Point value); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Point DesktopLocation { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.DesktopLocation : System.Drawing.Point with get, set
Public Property DesktopLocation As Point

Valeur de propriété

Point représentant la position du formulaire sur le bureau.

Attributs

Exemples

L’exemple suivant définit la position d’un formulaire de sorte que le formulaire soit positionné à 100 pixels de la bordure gauche du bureau et à 100 pixels du haut du bureau. Cet exemple nécessite que la méthode ait été définie dans une classe de formulaire.

public:
   void MoveMyForm()
   {
      // Create a Point object that will be used as the location of the form.
      Point tempPoint = Point( 100, 100 );
      // Set the location of the form using the Point object.
      this->DesktopLocation = tempPoint;
   }
public void MoveMyForm()
 {
    // Create a Point object that will be used as the location of the form.
    Point tempPoint = new Point(100,100);
    // Set the location of the form using the Point object.
    this.DesktopLocation = tempPoint;
 }
Public Sub MoveMyForm()
    ' Create a Point object that will be used as the location of the form.
    Dim tempPoint As New Point(100, 100)
    ' Set the location of the form using the Point object.
    DesktopLocation = tempPoint
End Sub

Remarques

Les coordonnées du bureau sont basées sur la zone de travail de l’écran, ce qui exclut la barre des tâches. Le système de coordonnées du bureau est basé sur des pixels. Si votre application s’exécute sur un système multimonitor, les coordonnées du formulaire sont les coordonnées du bureau combiné.

Vous pouvez utiliser cette propriété pour positionner votre formulaire par rapport à d’autres formulaires et applications sur le bureau Windows.

Si vous appelez la SetDesktopLocation méthode avant d’appeler la Show méthode, votre formulaire est positionné à son emplacement par défaut, qui est déterminé par le système d’exploitation. Pour plus d’informations sur le positionnement des fenêtres, consultez la section Taille et position de la fenêtre de l’article « Fonctionnalités de fenêtre ».

Si vous appelez SetDesktopLocation après l’appel Showde , votre formulaire sera positionné à l’emplacement que vous avez spécifié.

S’applique à

Voir aussi