Cursor.Hide 方法

定義

隱藏游標。Hides the cursor.

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

範例

下列程式碼範例會在滑鼠指標進入按鈕的工作區時隱藏游標。The following code example hides the cursor when the mouse pointer enters the button's client area. 同樣地,當滑鼠指標離開按鈕的工作區時,游標會再次顯示。Likewise, when the mouse pointer leaves the button's client area, the cursor is shown again. 這個範例需要 Form 具有名為 ButtonmyButtonThis example requires a Form with a Button named myButton.

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
      

備註

ShowHide 方法呼叫必須平衡。The Show and Hide method calls must be balanced. 對方法的每個呼叫都 Hide 必須有對應的 Show 方法呼叫。For every call to the Hide method there must be a corresponding call to the Show method.

適用於

另請參閱