|
|
|
|
|
- Overview
- Initializing a Table control populated programmatically
- Adding rows to a Table control populated programmatically
- Managing calculated columns
- Modifying a row or column
- Forcing the input
- Adding or deleting a column
- Operations on rows and cells
- Deleting a row
- Retrieving the content of a row or cell
- Value of the cell in the current row
- Value of a cell in a specific row
- Content of the current row
- Content of a specific row
Table populated programmatically: handling in WLanguage
Here is an overview of how to manipulate Table controls populated programmatically in WLanguage. There are multiple WLanguage functions to handle this type of control. To learn more on these functions, see the documentation. Initializing a Table control populated programmatically Rows are not created automatically in a Table control. This must be specified by calling: Note: if option "Cascading input (Add)" is not selected: - The Table control contains no rows when it is created:
TABLE_MyTable.Count = 0. In this case, no input is allowed and Empty is set to True. - To automatically insert rows into a Table control, write the following lines of code in the control initialization event:
IF TABLE_MaTable.Vide = True THEN TableAdd(TABLE_MaTable)
Adding rows to a Table control populated programmatically You can add rows to a Table control: Managing calculated columns The calculation formula of a calculated column must be defined in the "Display a row" event of a Table control. For example:
COL_PHT = COL_PUHT * COL_QTE
Modifying a row or column The content of the rows and columns in a Table control can be modified: - by the user, by entering data directly in the columns. The changes are automatically saved in the Table control (no additional code is required). The Modified property is set to True.
- programmatically:
- with TableModify to change the content of the current row or the content of a given row.
For example:
TableModify(TABLE_CLIENT, "PY" + TAB + "Jean" + TAB + "Nîmes")
Note: it is also possible to use the Table field name directly:
TABLE_CLIENT = "DURAND" + TAB +"Sophie" + TAB + "Nîmes"
TableModify(TABLE_JOUR, "Mercredi" + TAB + "Vaqué", 3)
- by specifying the name of the column to change the content (as for an Edit control). To modify the column of a specific row, the row number must be specified (index).
For example:
COL_NOM[Indice] = SAI_NomClient
To modify the column of the current row, there is no need to specify the index. For example:
The Modified property is set to False (it is set to True only when data is entered in the Table control).
IF NoSpace(COL_PRODUIT) = "" THEN
Error("La colonne Produit doit être saisie en premier")
SetFocusAndReturnToUserInput(COL_PRODUIT)
END
Operations on rows and cells Deleting a row You can delete rows by calling TableDelete. The syntax used is as follows:
TableSupprime(<Champ Table>[, <Indice>]) If the index is specified, TableDelete deletes the row that corresponds to that index. Otherwise, the current row is deleted. For example:
TableDelete(TABLE_CLIENT)
Deleting a row from a Table control also deletes all the values of the columns for that row. A row can be selected with TableSelectPlus. The syntax used is as follows:
TableSelectPlus(<Champ Table>[, <Indice>]) Retrieving the content of a row or cell The content of a Table control populated programmatically can be retrieved: - for the entire row.
- cell by cell.
Value of the cell in the current row To retrieve the value of a column (or cell) for the current row, the syntax is the same as for a simple Edit control.
IF COL_QTE < 10 THEN
Info("Qté insuffisante")
END
Value of a cell in a specific row To retrieve the value of a column that is not in the current row, you must specify the index of the row. <Valeur> = <Nom Colonne>[<Indice>] For example:
PrixTotal = 0
FOR Indice = 1 _TO_ TABLE_COMMANDE.Occurrence
PrixTotal = PrixTotal + COL_PHT[Indice]
END
Content of the current row To retrieve the content of the current row, use the following syntax: Content of a specific row To get the content of the row at index <Index>, use the following syntax: <Valeur> = <Champ Table>[<Indice>] Remark: The current line index can be known by the TableSelect function.. For example:
LigneEnCours = TABLE_CLIENT[10]
NomClient = COL_NOM[TableSelect(TABLE_CLIENT)]
LigneEnCours = TABLE_CLIENT
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|