Cursor.Show 方法

定义

显示光标。

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

示例

当鼠标指针进入按钮的工作区时,下面的代码示例隐藏光标。 同样,当鼠标指针离开按钮的工作区时,再次显示光标。 此示例需要Form具有命名myButtonButton

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

适用于

另请参阅