PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • 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 a cell in the current row
  • Value of a cell in a specific row
  • Content of the current row
  • Content of a specific row
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Overview
Here is an overview of how to handle Table controls populated programmatically in WLanguage.
WLanguage includes multiple functions to handle this type of control in the code. To learn more on these functions, see the documentation.
For more details, see Table control management functions.
Initializing a Table control populated programmatically
Rows are not created automatically in a Table control. This must be specified by calling:
Remark: if "Cascading input (Addition)" 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:
WINDEVJava If a new row was added to the Table control with TableAdd, TableInsert, TableAddLine or TableInsertLine, New is set to True (otherwise, it is set to False).
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: calculated column
// COL_UPBT and COL_QTY: columns populated programmatically
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")

      Remark: you can also use the name of the Table control directly:
      // Modify the current row
      TABLE_CUSTOMER = "MOORE" + TAB +"Vince" + TAB + "Miami"
      // Modify row 3
      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).
WINDEVWindowsJavaUser code (UMC)

Forcing the input

SetFocusAndReturnToUserInput can be used to resume input in a column, on the current row.
For example:
// Entry process in the COL_QTY column
// COL_QTY cannot be entered,
// if COL_PRODUCT is not entered
IF NoSpace(COL_PRODUCT) = "" THEN
Error("The Product column must be entered first")
SetFocusAndReturnToUserInput(COL_PRODUCT)
END
WINDEVWindowsJavaUser code (UMC)

Adding or deleting a column

You can:
  • Add a column to a Table control populated programmatically with ControlClone.
  • Delete a column from a Table control populated programmatically with ControlDelete.
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 a 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.
<Value> = <Column name>
Example:
// COL_QTY is a column of the Table 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:
// Add the total price before tax (PBT) for all the order lines
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 index of the current row is returned by TableSelect.
For example:
// Retrieve row #10 in the TABLE_CUSTOMER control
CurrentRow = TABLE_CUSTOMER[10]
 
// Name of selected customer
CustomerName = COL_NAME[TableSelect(TABLE_CUSTOMER)]
 
// Retrieve the current row in the TABLE_CUSTOMER control
CurrentRow = TABLE_CUSTOMER
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment