Control.Hide 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
隱藏控制權,不讓使用者知道。
public:
void Hide();
public void Hide();
member this.Hide : unit -> unit
Public Sub Hide ()
範例
以下程式碼範例說明,若按下 CTRL 鍵並點擊按鈕,該按鈕會隱藏。 這個例子要求你在 上Form有一個Button名稱button1。
private:
void button1_Click( Object^ sender, System::EventArgs^ /*e*/ )
{
/* If the CTRL key is pressed when the
* control is clicked, hide the control. */
if ( Control::ModifierKeys == Keys::Control )
{
(dynamic_cast<Control^>(sender))->Hide();
}
}
private void button1_Click(object sender, System.EventArgs e)
{
/* If the CTRL key is pressed when the
* control is clicked, hide the control. */
if(Control.ModifierKeys == Keys.Control)
{
((Control)sender).Hide();
}
}
Private Sub button1_Click(sender As Object, _
e As EventArgs) Handles button1.Click
' If the CTRL key is pressed when the
' control is clicked, hide the control.
If Control.ModifierKeys = Keys.Control Then
CType(sender, Control).Hide()
End If
End Sub
備註
隱藏控制項等同於將屬性設 Visible 為 false。 呼叫該方法後 Hide ,該 Visible 屬性會回傳一個值, false 直到呼叫該 Show 方法為止。