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

注解

ShowHide 方法调用必须均衡。 对于对 方法的 Hide 每次调用,都必须有对 方法的 Show 相应调用。

适用于

另请参阅