PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Method 1: Using the TableSelect function
  • Example
  • Method 2: Using the FOR EACH statement
  • Example
  • Method 3: Using a Check Box column
  • Code example
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
By default, a single row can be selected in a Table control. However, the Table control can be configured in order to become multi-selection. In this case, the user will have the ability to select several rows and to retrieve these rows by programming.
The "multi-selection" parameter of Table control is found in the "GUI" tab of the description window of control.
The multi-selection is performed via the SHIFT and CTRL keys, the arrows and/or the mouse.
Then, 3 methods can be used to retrieve the selected rows:
Method 1: Using the TableSelect function
This method consists in performing a browse loop and in browsing rows with TableSelect.
A variable representing the rank of the selected list will be incremented from the value 1.
  • If TableSelect returns -1: there is no other selected rows.
  • If TableSelect returns a value greater than 0: this value represents the position of the selected row in the Table control.
To retrieve the value of the selected element, use the following syntax:
NameTableControl.ColumnName[Subscript]
Note: To find out the number of selected rows, use TableSelectCount. This allows you to perform a loop with a FOR statement instead of a WHILE statement.

Example

Rank is int
RowPosition is int
ColumnValue is string

Rank = 1
RowPosition = TableSelect(NameTableControl, Rank)
WHILE RowPosition <>-1
ElementValue = NameTableControl.ColumnName[RowPosition]
Rank++
RowPosition = TableSelect(NameTableControl, Rank)
END
Method 2: Using the FOR EACH statement
This method consists in browsing the selected rows with a specific FOR EACH statement.

Example

FOR EACH SELECTED ROW OF NameTableControl
// Process the selected row
END
Method 3: Using a Check Box column
Instead of using the multi-selection mechanism of Table control, you have the ability to use a Check Box column to manage the selection. This column must be in edit in the Table control.
In this case:
  • if the box found in the check box is checked, the row is selected.
  • if the box is not checked, the row is not selected.
All you have to do is browse all the rows found in the Table control and check whether the box is checked for each row.

Code example

Sub is int

FOR Sub = 1 TO TableCount(NameTableControl)
IF NameTableControl.Col_CheckBox[Sub] = True THEN
// Process the selected row
END

END
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment