delphitabbed-document-interface

Merge tabs from child form into main form


I have page control in main form and page controls in child form , I place the child form inside the main form by using docking features.

I am not using MDI style

Now both forms have tabs in page control and I need to merge the child form tabs into the main form page control, what is the best way to do that?


Solution

  • This is a fairly simple approach that may or may not suit your needs.

    For each child tab page you need to merge:

    You do not need to deal with controls that are children of other controls. e.g. if you have a groupbox in your child tab, then changing it's parent will bring both it and all controls within it to the new parent.

    If you need to be able to "unmerge" your tabs at any point then you will need to devise some mechanism to keep track of where the controls came from so you can restore the original Parent as/when needed.

    To make things slightly easier you could place a TPanel in the child tabs, with it's Align property set to alClient. Place all the controls in the tab on that panel and then when you need to merge/unmerge you need only set the Parent of the panel control.