Share via


Cursor.Position Eigenschaft

Definition

Ruft die Position des Cursors ab oder legt diese fest.

public:
 static property System::Drawing::Point Position { System::Drawing::Point get(); void set(System::Drawing::Point value); };
public static System.Drawing.Point Position { get; set; }
member this.Position : System.Drawing.Point with get, set
Public Shared Property Position As Point

Eigenschaftswert

Point

Ein Point in Bildschirmkoordinaten, der die Position des Cursors darstellt.

Beispiele

Im folgenden Codebeispiel wird ein Cursor aus dem Current Cursor Handleerstellt, dessen Position und das Clippingrechteck geändert. Das Ergebnis ist der Cursor, der nach oben verschoben wird, und nach links 50 Pixel, von wo aus der Code ausgeführt wird. Darüber hinaus wird das Clippingrechteck des Cursors in die Grenzen des Formulars geändert (standardmäßig ist es der gesamte Bildschirm des Benutzers). In diesem Beispiel muss dieser Form Code aufgerufen werden Button , wenn er geklickt wird.

void MoveCursor()
{
   // Set the Current cursor, move the cursor's Position,
   // and set its clipping rectangle to the form.

   this->Cursor = gcnew System::Windows::Forms::Cursor( ::Cursor::Current->Handle );
   ::Cursor::Position = Point(::Cursor::Position.X - 50,::Cursor::Position.Y - 50);
   ::Cursor::Clip = Rectangle(this->Location,this->Size);

}
private void MoveCursor()
{
   // Set the Current cursor, move the cursor's Position,
   // and set its clipping rectangle to the form. 

   this.Cursor = new Cursor(Cursor.Current.Handle);
   Cursor.Position = new Point(Cursor.Position.X - 50, Cursor.Position.Y - 50);
   Cursor.Clip = new Rectangle(this.Location, this.Size);
}
Private Sub MoveCursor()
   ' Set the Current cursor, move the cursor's Position,
   ' and set its clipping rectangle to the form. 

   Me.Cursor = New Cursor(Cursor.Current.Handle)
   Cursor.Position = New Point(Cursor.Position.X - 50, Cursor.Position.Y - 50)
   Cursor.Clip = New Rectangle(Me.Location, Me.Size)
End Sub

Hinweise

Die Position Eigenschaft ist identisch mit der Control.MousePosition Eigenschaft.

Gilt für

Siehe auch