Cursor.Position Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur posisi kursor.
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; }
static member Position : System.Drawing.Point with get, set
Public Shared Property Position As Point
Nilai Properti
Point yang mewakili posisi kursor dalam koordinat layar.
Contoh
Contoh kode berikut membuat kursor dari Current kursor Handle, mengubah posisinya dan mengklip persegi panjang. Hasilnya adalah kursor akan bergerak ke atas dan ke kiri 50 piksel dari tempatnya ketika kode dijalankan. Selain itu, persegi panjang kliping kursor diubah ke batas formulir (secara default adalah seluruh layar pengguna). Contoh ini memerlukan Form dan Button untuk memanggil kode ini saat diklik.
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
Keterangan
Properti Position ini identik dengan Control.MousePosition properti .