Cursor.Hide Method

Definition

Hides the cursor.

C#
public static void Hide();

Examples

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. This example requires a Form with a Button named myButton.

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();
}

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.

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also