Control.Hide Metod

Definition

Döljer kontrollen från användaren.

public:
 void Hide();
public void Hide();
member this.Hide : unit -> unit
Public Sub Hide ()

Exempel

I följande kodexempel döljs en knapp om CTRL-tangenten trycks ned när knappen klickas. Det här exemplet kräver att du har ett Button namn button1 på en Form.

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

Kommentarer

Att dölja kontrollen motsvarar att ställa in egenskapen på Visiblefalse. Hide När metoden har anropats Visible returnerar egenskapen värdet false tills Show metoden anropas.

Gäller för

Se även