Cursor.Hide 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
可以隱藏游標。
public:
static void Hide();
public static void Hide();
static member Hide : unit -> unit
Public Shared Sub Hide ()
範例
以下程式碼範例在滑鼠指標進入按鈕的用戶端區域時,會隱藏游標。 同樣地,當滑鼠指標離開按鈕的客戶端區域時,游標會再次顯示。 此範例需要一個Form,Button且 myButton 為 。
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 的方法呼叫。