C++ Builder Tutorials

C++Builder Tips: Hiding components

If you want to show or hide a group of components from time to time, put these components on a separate panel. Next, show or hide the panel as needed. You can do this in two different ways:

  • using the panel's methods Show and Hide:
    Panel1->Show;
    //... at some later time:
    Panel1.Hide;
  • or using the panel's property Visible:
    Panel1->Visible := true;
    //... at some later time:
    Panel1->Visible := false;
    
    
 
To quickly "toggle" the visibility by clicking a button, write this OnClick event handler for the button:
void __fastcall TForm1::Button1(TObject *Sender)
{
  Panel1->Visible = !(Panel1->Visible);
}