property indicates the procedure to be called when a row in a TreeView or TreeView Table control is clicked to be expanded. This procedure populates only the expanded branches.
This optimizes the control population procedure.
Remark: To optimize how TreeView and TreeView Table controls based on a data file are populated, check "Delayed fill of sub-levels (faster)" in the "Content" tab of the control description window.
sDir is string = fListDirectory("C:", frNotRecursive)
FOR EACH STRING sADir OF sDir SEPARATED BY CR
nLine is int = TableAddLine(TVT_Explorer, sADir)
// If this directory has children
sChild is string = fListDirectory(sADir, frNotRecursive)
IF sChild <> "" THEN
// Call to the AddDirectory procedure
// when the user clicks [+]
TVT_Explorer[nLine].AddChildDelayed = AddDirectory
PROCEDURE AddDirectory(sParentID is string)
nIndex is int
sParentDir is string = TVT_Explorer.COL_NoName1[sParentID]
sParentDir = Replace(sParentDir, TAB, fSep())
sDirList is string = fListDirectory(sParentDir, frNotRecursive)
nIndex = Val(sParentID) + 1
nIndex2 is int = nIndex
FOR EACH STRING sDir OF sDirList SEPARATED BY CR
sID is string = Replace(sDir, "\", TAB)
TableAddChild(TVT_Explorer, nIndex-1, sDir)
sSubDirList is string = fListDirectory(sDir, frNotRecursive)
IF sSubDirList <> "" THEN
TVT_Explorer[nIndex2].AddChildDelayed = AddDirectory
nIndex2 = nIndex2 + 1
Modifying the procedure to execute Hide the details
<Element>.AddChildDelayed = <WLanguage procedure>
<Element>: Character string
Row of the Table or TreeView Table control to use.
<WLanguage procedure>: Procedure name
Name of the WLanguage procedure to be executed when the element is clicked.
For TreeView controls, the procedure has the following format:
PROCEDURE <Procedure name>(<ParentPath> is string)
where <ParentPath> corresponds to the full path of the row to expand.
For TreeView Table controls, the procedure has the following format:
PROCEDURE <Procedure name>(<ParentID> is int)
where <ParentID> corresponds to the number of the row to expand.
If this parameter is an empty string (""), no procedure will be associated with the element.
If the AddChildDelayed property corresponds to the name of a procedure:
- a "+" sign is displayed on the row in the control.
- the first time the user tries to expand the row (by clicking the "+" sign for example), the procedure is called, allowing to add child elements. Then, the branch is expanded.
If no child element is added, the "+" sign is deleted from the element.
Once the procedure has been executed (the branch has been populated), an empty string is assigned to the AddChildDelayed property: it will no longer be executed.
- The specified procedure will be executed BEFORE the "Collapse/expand a node" event of the control.
- When the TableExpand or TreeExpand functions are called, if the specified branch has a procedure associated via the AddChildDelayed property, this procedure will be executed.
- When the TableExpandAll or TreeExpandAll functions are called, if the specified branch and/or one of its children has an associated procedure via the AddChildDelayed property, this procedure will be executed.