|
|
|
|
|
- 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_MyTable.Empty = True THEN TableAdd(TABLE_MyTable)
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_PBT = COL_UPBT * COL_QTY
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_CUSTOMER, "MOORE" + TAB + "Vince" + TAB + "Miami")
Note: it is also possible to use the Table field name directly:
TABLE_CUSTOMER = "MOORE" + TAB +"Vince" + TAB + "Miami"
TableModify(TABLE_DAY, "Wednesday" + TAB + "Off", 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_NAME[Index] = EDT_CustomerName
To modify the column of the current row, there is no need to specify the index. For example:
COL_NAME = EDT_CustomerName
The Modified property is set to False (it is set to True only when data is entered in the Table control).
IF NoSpace(COL_PRODUCT) = "" THEN
Error("The Product column must be entered first")
SetFocusAndReturnToUserInput(COL_PRODUCT)
END
Operations on rows and cells Deleting a row You can delete rows by calling TableDelete. The syntax used is as follows:
TableDelete(<Table control>[, <Index>]) If the index is specified, TableDelete deletes the row that corresponds to that index. Otherwise, the current row is deleted. For example:
TableDelete(TABLE_CUSTOMER)
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(<Table control>[, <Index>]) 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_QTY < 10 THEN
Info("Insufficient quantity")
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. <Value> = <Column name>[<Index>] For example:
TotalPrice = 0
FOR Index = 1 _TO_ TABLE_ORDER.Count
TotalPrice = TotalPrice + COL_PBT[Index]
END
Content of the current row To retrieve the content of the current row, use the following syntax: <Value> = <Table control> Content of a specific row To get the content of the row at index <Index>, use the following syntax: <Value> = <Table control>[<Index>] Remark: The current line index can be known by the TableSelect function.. For example:
CurrentRow = TABLE_CUSTOMER[10]
CustomerName = COL_NAME[TableSelect(TABLE_CUSTOMER)]
CurrentRow = TABLE_CUSTOMER
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|