Search code examples
delphidelphi-11-alexandria

How to change order of TTabSheets in an inherited TPageControl?


Usually what I do to change the order of TabSheets in a PageControl is:

  1. Right-click on the Form and choose "View as Text"

  2. Manually edit the source DFM to put the TabSheets in the desired order

  3. Right-click on the source and choose "View as Form"

Although it's a hassle, this procedure works.

But now, I have a new situation. I'm using a Form that inherits from another Form that already has a PageControl with 2 TabSheets. I need to add a third tab, but this needs to be the second in order. No matter what I do in the DFM source code, I can't change the second inherited TabSheet to be the third page in the PageControl.

Is there an alternative way to achieve changing the order of TabSheets in a inherited Form?


Solution

  • Probably it's easiest to handle this in code: Set the TabSheet's PageIndex property in the Form's constructor or OnCreate event.