Search code examples
delphivcl

Opening a new form with specific tab


I was hoping that something like this should work:

Form2.Show();
Form1.Hide();
Form2.PageControl1.ActivePage := TabSheet1;

The thing is that I have a multiple buttons (in the first form), and I want for each one of them to open the new form in a specific tab of the PageControl.

Error: Undeclared identifier: 'TabSheet1'


Solution

  • The message shows that TabSheet1 is not defined - and that is probably (although don't show us the full code) because you are outside the parent object, so you need the line

    Form2.PageControl1.ActivePage := Form2.TabSheet1;