ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / Developing an application or website / Controls, windows and pages / Controls: Available types / Looper control
  • Overview
  • How to?
  • Including a Table control in a Looper control
  • Including a control in a Looper control
  • Accessing the contents of internal window fields from the host window
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
In a Looper control, a different content can be assigned to the Table, Chart, List Box and TreeView controls:
  • If the control to repeat is a Table control or a Chart control, all you have to do is insert it into the Looper control directly.
  • If the control to repeat is another type of control (List Box control, TreeView control, etc.), simply insert this control into an internal window. Then, all you have to do is create the associated Internal Window control in the Looper control.
Remark: Table, Chart control or internal window fields must be populated programmatically.
How to?

Including a Table control in a Looper control

To include a Table control in a Looper control:
  1. If necessary, create a RepeatString Looper control: RepeatString file, by programming or variable.
  2. Insert the Table control into the Looper control. The Table control must be populated programmatically.
  3. Make sure that "Identical content for all the rows" is unchecked ("UI" tab in the description window of the Table control).
  4. The Table control can now be populated programmatically.
The Table control found in the Looper control can be filled by using TableAddLine according to the following method:
TableAddLine(<Name of Looper control>[Row index].<Name of Table control>,
<Element Column 1>, <Element Column 2>, ...)
Example The following code fills the Table control in the RepeatString field. The Looper control lists the orders and the Table control lists the products ordered.
The following code is used to populate both the Looper control and the Table control:
PROCEDURE FillOrdersOfTheDay()

// Local variables
nIndex is int

// Clears the Looper control
LooperDeleteAll(LOOP_OrdersOfTheDay)

// Browse the orders of the day
FOR EACH Order WITH "OrderDate = '"+Today() + "' AND IsFinalized = 0"

	// Finds the associated contact
	HReadSeekFirst(CustomerContact, CustomerContactID, Order.CustomerContactID)
	IF HFound(CustomerContact) = False THEN CONTINUE

	// Adds a row into the Looper control
	nIndex = LooperAddLine(LOOP_OrdersOfTheDay, Order.OrderID, ...
			CustomerContact.Company, CustomerContact.LastName + ...
			[" "] + CustomerContact.FirstName)

	// Browses the order lines
	FOR EACH OrdLine WITH OrderID = Order.OrderID
		HReadSeekFirst(Product, ProductID, OrdLine.ProductID)
		IF HFound(Product) = False THEN CONTINUE

		// Add the ordered elements into the Table control
		TableAddLine(LOOP_OrdersOfTheDay[nIndex].TABLE_Order, ...
			Product.ProductID, Product.Caption, OrdLine.Quantity)
	END
END
For a simpler syntax, it is possible to fill a line in the RepeatString Looper control directly in the display code.. In this case, there is no need to specify the index of the main looper. The syntax becomes:
TableAddLine(<Name of Table control>, <Element column 1>, <Element column 2>, ...)
Tip In the display code for a line in the RepeatString field, remember to empty the Table control before filling it with the TableDeleteAll function.

Including a control in a Looper control

To integrate another control (List Box, TreeView, etc.) into the Looper control:
  1. If necessary, create a RepeatString Looper control: RepeatString file, by programming or variable.
  2. Insert an Internal Window control into the Looper control.
  3. Make sure that "Identical content for all the rows" is unchecked ("UI" tab in the description of the Internal Window control).
  4. Create an internal window if necessary. Insert the control (Chart, List Box, TreeView, etc.) into this internal window. The inserted control must be populated programmatically.
  5. Associate the Internal Window control with the internal window ("General" tab in the description of Internal Window control).
  6. The control can now be populated programmatically.
For example, TreeAdd can be used as follows in order to fill a TreeView control found in a Looper control:
TreeAdd(<Name of Looper control>[Row index].
<Name of Internal Window>.<Name of TreeView Control>, <Element to Add>)

Accessing the contents of internal window fields from the host window

To access the contents of the internal window's fields from the host window, simply manipulate the desired row, the internal window and then the field..
Example: Retrieve the value of a date-type Edit control from the first occurrence of the RepeatString Looper control:
x is Field <- ZR_SansNom1[1]
Trace(x.FI_SansNom1.SAI_DATE)
Minimum version required
  • Version 16
Comments
Click [Add] to post a comment

Last update: 01/16/2025

Send a report | Local help