This documentation is archived and is not being maintained.

Control.Hide Method

Conceals the control from the user.

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

Remarks

Hiding the control is equivalent to setting the Visible property to false. After the Hide method is called, the Visible property returns a value of false until the Show method is called.

Example

[Visual Basic, C#, C++] The following example hides a button when the CTRL key is pressed while the button is clicked. This example assumes you have a Button named button1 on a Form.

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

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

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

[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

See Also

Control Class | Control Members | System.Windows.Forms Namespace | Visible | Show

Show: