|
|
|
|
|
- Overview
- Method 1: Cloning columns
- Method 2: Creating columns
- Using the new column
How to clone and use columns in a Table control?
In some cases, a Table control must be filled with an unknown number of columns (when creating the control). Two methods can be used to dynamically build columns in a Table control: Method 1: Cloning columns ControlClone is used to clone (duplicate) an existing control in order to create a copy. This function can also be used on a column found in a Table control. The new column is automatically added at the end of the existing columns. To create a new column: - Create a Table control.
- In the Table control, define the column that will be used as "template for cloning".
- Clear the content of Table control (TableDeleteAll).
- Delete the previous cloned columns (ControlDelete).
- Create the new columns (ControlClone).
- Fill the Table control with data.
Code sample: NbFixedColumns is int
NbNewColumns is int
NewColumnName is string
TableDeleteAll(TABLE_YearlyStat)
NbFixedColumns = 3
FOR nIndex = TableCount(TABLE_YearlyStat,toColumn) TO NbFixedColumns STEP -1
ControlDelete(TableEnumColumn(TABLE_YearlyStat, nIndex))
END
NbNewColumns = 5
FOR nIndex = 1 TO NbNewColumns
NewColumnName = "COL_" + nIndex
ControlClone(COL_Template, NewColumnName)
{NewColumnName, indControl}..Caption = "Column " + nIndex
END
Caution: - The columns must be cloned before filling the Table control.
- Two columns cannot have the same name.
Method 2: Creating columns ControlCreate allows you to create a control without having to use a template. This function can also be used on a column found in a Table control. The new column is automatically added at the end of the existing columns. To create a new column: - Create a Table control.
- Clear the content of Table control (TableDeleteAll).
- Delete the previous created columns (ControlDelete).
- Create the new columns (ControlCreate).
- Fill the Table control with data.
Code sample: NewColumn is Control
NbFixedColumns is int
NbNewColumns is int
NewColumnName is string
TableDeleteAll(TABLE_YearlyStat)
NbFixedColumns = 3
FOR nIndex = TableCount(TABLE_YearlyStat, toColumn) TO NbFixedColumns STEP -1
ControlDelete(TableEnumColumn(TABLE_YearlyStat, nIndex))
END
NbNewColumns = 5
FOR nIndex = 1 TO NbNewColumns
NewColumnName = TABLE_YearlyStat.Name + ".COL_" + nIndex
NewColumn <- ControlCreate(NewColumnName, typColumn)
NewColumn.Caption = "Column" + nIndex
END
Caution: - The columns must be created before filling the Table control.
- Two columns cannot have the same name.
Two methods can be used to handle the created column:
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|