Cursor.Hide メソッド

定義

カーソルを非表示にします。

public:
 static void Hide();
public static void Hide ();
static member Hide : unit -> unit
Public Shared Sub Hide ()

次のコード例では、マウス ポインターがボタンのクライアント領域に入ったときにカーソルを非表示にします。 同様に、マウス ポインターがボタンのクライアント領域から離れると、カーソルが再び表示されます。 この例では、 という名前の がForm必要ですButtonmyButton

private:
   void myButton_MouseEnter( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      // Hide the cursor when the mouse pointer enters the button.
      ::Cursor::Hide();
   }

   void myButton_MouseLeave( Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      // Show the cursor when the mouse pointer leaves the button.
      ::Cursor::Show();
   }
private void myButton_MouseEnter(object sender, System.EventArgs e)
{
   // Hide the cursor when the mouse pointer enters the button.
   Cursor.Hide();
}

private void myButton_MouseLeave(object sender, System.EventArgs e)
{
   // Show the cursor when the mouse pointer leaves the button.
   Cursor.Show();
}
Private Sub myButton_MouseEnter(sender As Object, e As System.EventArgs) Handles myButton.MouseEnter
   ' Hide the cursor when the mouse pointer enters the button.
   Cursor.Hide()
End Sub
      
      
Private Sub myButton_MouseLeave(sender As Object, e As System.EventArgs) Handles myButton.MouseLeave
   ' Show the cursor when the mouse pointer leaves the button.
   Cursor.Show()
End Sub

注釈

Showメソッド呼び出しと Hide メソッド呼び出しのバランスを取る必要があります。 メソッドの呼び出しごとに、 Hide メソッドの対応する呼び出しが Show 必要です。

適用対象

こちらもご覧ください