共用方式為


Cursor.Position 屬性

定義

取得或設定游標的位置。

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

屬性值

Point

Point,代表在螢幕座標中的滑鼠位置。

範例

下列程式碼範例會從 Current 游標的 Handle 建立資料指標,並變更其位置和裁剪矩形。 結果是游標會向上移動,並在執行程式碼時,向左移動 50 圖元。 此外,游標的裁剪矩形預設會變更為表單界限, (預設為使用者的整個螢幕) 。 這個範例需要 Form 和 , Button 才能在按一下時呼叫此程式碼。

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

備註

屬性 PositionControl.MousePosition 屬性相同。

適用於

另請參閱