Control Methods


.NET Framework Class Library
Control..::.Hide Method

Conceals the control from the user.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
Syntax

Visual Basic (Declaration)
Public Sub Hide
Visual Basic (Usage)
Dim instance As Control

instance.Hide()
C#
public void Hide()
Visual 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.

Examples

The following code example hides a button if the CTRL key is pressed when the button is clicked. This example requires that 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();
   }
}
Visual 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();
      }
   }
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0
See Also

Reference

Tags :


Page view tracker