共用方式為


Control.Hide 方法

定義

隱藏控制權,不讓使用者知道。

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

備註

隱藏控制項等同於將屬性設 Visiblefalse。 呼叫該方法後 Hide ,該 Visible 屬性會回傳一個值, false 直到呼叫該 Show 方法為止。

適用於

另請參閱