Cursor.Hide 方法

定義

可以隱藏游標。

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

範例

以下程式碼範例在滑鼠指標進入按鈕的用戶端區域時,會隱藏游標。 同樣地,當滑鼠指標離開按鈕的客戶端區域時,游標會再次顯示。 此範例需要一個FormButtonmyButton 為 。

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 方法呼叫必須平衡。 對於每一次呼叫該 Hide 方法,都必須有對應 Show 的方法呼叫。

適用於

另請參閱