Export (0) Print
Expand All

Cursor.Hide Method

Hides the cursor.

[Visual Basic]
Public Shared Sub Hide()
[C#]
public static void Hide();
[C++]
public: static void Hide();
[JScript]
public static function Hide();

Remarks

The Show and Hide method calls must be balanced. For every call to the Hide method there must be a corresponding call to the Show method.

Example

[Visual Basic, C#, C++] The following 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. This example assumes you have a Form with a Button named myButton.

[Visual Basic] 
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 'myButton_MouseEnter
      
      
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 'myButton_MouseLeave
      

[C#] 
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();
}

[C++] 
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();
    }

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

.NET Framework Security: 

See Also

Cursor Class | Cursor Members | System.Windows.Forms Namespace | Show

Show:
© 2014 Microsoft