ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / How to proceed? / Programming
  • 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/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
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 through programming.
The "Multiple" row selection mode can be selected in the "UI" tab of the control description window.
Multi-selection can be performed via the standard 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 the Table control, it is possible 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 version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 10/27/2022

Send a report | Local help