Skip to Content

How to Dynamically Add Tab Pages with GUI Controls to a Tab Control

Estimated Reading Time: 1 Minutes

You can decide at runtime whether specific pages should be added to a tab control, based on the nature of the data or specific data values. Additionally, you can dynamically populate those pages with any GUI controls you need.

For example, if you declare a tab control in the screen section like this:

    03 Tb1-container
       tab-control
       line                 5
       col                  2
       lines                17 cells
       size                 68 cells
       allow-container
       .

For example, if you declare a tab control in the screen section like this:

    modify Tb1-container    tab-to-add ("page1", "page2")

To add dynamic controls to each new page, remember that every tab page is indexed by an incremental integer. Typically, you can display the new dynamic GUI controls on the desired tab page by referencing its index.

For example, if you want to add a label and an entry field to page 3 of the tab control, you would do something like this:
(In the following code, the variable t1-next-page has a value of 3, and label-title contains the text you want for the label.)

    display label line 8 col 4 title label-title
            upon Tb1-Container(t1-next-page)
    display entry-field line 10 col 4
            upon Tb1-Container(t1-next-page)

Attached is a complete sample program you can download that demonstrates this functionality.

Compile it with:

iscc dyntab.cbl

Run it with:

iscrun DYNTAB
How to Dynamically Add Tab Pages with GUI Controls to a Tab Control
  • Attached Files
  • dyntab.cbl (4.01 KB) 18