Freigeben über


Form.DesktopLocation-Eigenschaft

Ruft die Position des Formulars auf dem Windows-Desktop ab oder legt diese fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Property DesktopLocation As Point
'Usage
Dim instance As Form
Dim value As Point

value = instance.DesktopLocation

instance.DesktopLocation = value
public Point DesktopLocation { get; set; }
public:
property Point DesktopLocation {
    Point get ();
    void set (Point value);
}
/** @property */
public Point get_DesktopLocation ()

/** @property */
public void set_DesktopLocation (Point value)
public function get DesktopLocation () : Point

public function set DesktopLocation (value : Point)

Eigenschaftenwert

Ein Point, der die Position des Formulars auf dem Desktop darstellt.

Hinweise

Desktopkoordinaten beruhen auf dem Arbeitsbereich des Bildschirms, wobei die Taskleiste nicht mitgerechnet wird. Die Koordinaten des Desktops werden in Pixel angegeben. Wenn die Anwendung auf einem System mit mehreren Bildschirmen ausgeführt wird, beziehen sich die Koordinaten des Formulars auf den kombinierten Desktop.

Mit dieser Eigenschaft können Sie die Position eines Formulars relativ zu anderen Formularen und Anwendungen auf dem Windows-Desktop bestimmen.

Wenn Sie die SetDesktopLocation-Methode vor dem Aufruf der Show-Methode aufrufen, wird das Formular an der durch das Betriebssystem festgelegten Standardposition platziert. Weitere Informationen zur Positionierung von Fenstern finden Sie in der MSDN-Bibliothek unter https://msdn.microsoft.com/library/deu. im Dokument "Window Features" im Abschnitt "Window Size and Position".

Wenn Sie SetDesktopLocation nach dem Aufruf von Show aufrufen, wird das Formular an der von Ihnen angegebenen Position platziert.

Beispiel

Im folgenden Codebeispiel wird die Position eines Formulars so festgelegt, dass sich das Formular 100 Pixel rechts vom linken und 100 Pixel unter dem oberen Rand des Desktops befindet. Für dieses Beispiel ist es erforderlich, dass die Methode in einer Formularklasse definiert ist.

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 'MoveMyForm
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:
   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.set_DesktopLocation(tempPoint);
} //MoveMyForm

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Form-Klasse
Form-Member
System.Windows.Forms-Namespace
Form.DesktopBounds-Eigenschaft