delphitabspagecontrol

Avoiding duplicate Tabs on tcxPageControl created at Runtime


I am using tcxPageControl and tcxTabSheet to create a several Tabs. Each Tab is created at Runtime, based on a registry from tbl_Manager. This table keep the name of manager of each employee, and the Tabs are the name of manager.

PROBLEM

The name of manager is repeated many times, how can I avoid to create Tabs with the same name and create only one Tabper manager?


Solution

  • Keep track of which tabs you've created before, and only create tabs for names you haven't already seen.

    If you're selecting the manager names from an SQL query, then use DISTINCT so you get a list of unique values.

    You could add all the manager names to a TStringList with Sorted = True and Duplicates = dupIgnore. Once you've added all the names, you can read back the contents of the list, and it will be free of duplicates.