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 / TreeView Table control
  • Overview
  • Initializing a TreeView Table control
  • Adding or modifying rows in a TreeView Table control
  • Adding rows to a TreeView Table control
  • Modifying a row or column
  • Resuming input in a column
  • Adding or deleting a column
  • Managing calculated columns
  • Operations on rows and cells
  • Deleting a row
  • Selecting a row
  • Retrieving the content of a row or cell
  • Value of the cell in the current row
  • Value of a cell in a specific row
  • Content of the current row
  • Content of a specific row
  • Operations on the tree structure
  • Collapsing all the nodes of a TreeView Table control
  • Expanding all the nodes of a TreeView Table control
  • Getting the number of the collapsed/expanded row
  • Defining the state of new rows
  • Getting and setting the images of the rows
  • TreeView column with Check Box
  • Getting the parent or children of an element
  • Properties specific to TreeView Table controls
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Overview
This page explains how to program TreeView Table controls. There are multiple WLanguage functions to programmatically manipulate TreeView Table controls.
To learn more on these functions, see the documentation. For more details, see list of functions specific to TreeView Table controls.
Initializing a TreeView Table control
To programmatically populate a TreeView Table control, can use the following functions:
If a new row was added into a TreeView Table control by TableAdd, TableInsert, TableAddLine, TableAddChild, TableInsertLine or TableInsertChild, the New property is set to True (otherwise, it is set to False).
WINDEV Remark: To optimize the filling of a TreeView Table control, you can use the AddChildDelayed property on TreeView Table control rows..
In this case, the principle for populating the control is simplified:
  • When initializing the control, only the first-level elements are loaded. Each element is associated with the AddChildDelayed property.
  • When the user clicks the element on the first level to expand it, the procedure defined by the AddChildDelayed property is executed. This procedure fills the level to expand. Child nodes are only retrieved on demand from the user.
Adding or modifying rows in a TreeView Table control

Adding rows to a TreeView Table control

Rows are not created automatically in TreeView Table controls. This must be specified by calling:
WINDEV Note: If the "Cascade input" option is not selected:
  • The TreeView Table control doesn't have any rows when it is created. In this case, no input can be performed. The Empty property is set to True.
  • To automatically insert a row into an empty TreeView Table control, use TableAdd or TableAddLine.

Modifying a row or column

The contents of the rows and columns in a TreeView Table control can be modified:
  • by the user, by entering data directly in the columns. The changes are automatically saved in the TreeView Table control (no additional code is required). The Modified property is set to True.
  • programmatically:
    • with TableModify or TableModifyLine to modify the contents of the current row or a specific row.
      For example:
      TableModify(TVT_CUSTOMER, "MOORE" + TAB + "Vince" + TAB + "Miami")

      Note: It is also possible to use the TreeView Table control name directly:
      // Modify the current row
      TVT_CUSTOMER = "MOORE" + TAB + "Vince" + TAB + "Miami"
      // Modify the COL_DAY coloumn of row 3
      TableModify(COL_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] = CustomerName

      To modify the column of the current row, there is no need to specify the index.
      For example:
      COL_NAME = CustomerName

      The Modified property is set to False (it is set to True only when data is entered in the TreeView Table control).
WINDEV

Resuming input in a column

SetFocusAndReturnToUserInput can be used to resume input in a column, on the current row. For example:
// Event "Entry in" COL_QTY
// 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
WINDEV

Adding or deleting a column

You can:

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_PHT: calculated column
// COL_PUHT and COL_QTE: columns linked to memory zones
COL_PBT = COL_UPBT * COL_QTY
Operations on rows and cells

Deleting a row

To remove a row, you need to call TableDelete or TableDeleteChild.
  • The syntax used for TableDelete is as follows:
    TableDelete(<TreeView Table control> [, <Index>])

    If the index is specified, TableDelete deletes the row that corresponds to that index. Otherwise, the current row is deleted.
    Deleting a row from the TreeView Table deletes all the values of the columns for that row.
  • The syntax used for TableDeleteChild is as follows:
    TableDeleteChild(<TreeView Table control>, <Parent element index>)

    All child elements of the row identified by the index will be deleted.

Selecting a row

A row can be selected with TableSelectPlus.
The syntax used is as follows:
TableSelectPlus(<TreeView Table control>[, <Index>])

Retrieving the content of a row or cell

The contents of a TreeView Table control can be retrieved:
  • for the entire row.
  • cell by cell.

Value of the 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>
For example:
// COL_QTY is a column of a TreeView 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 TVT_ORDER.Count
TotalPrice = TotalPrice + COL_PBT[Index]
END

Content of the current row

To retrieve the content of current row:
<Value> = <TreeView Table control>

Content of a specific row

To retrieve the contents of the row whose index is <Index>, use the following syntax:
<Value> = <TreeView Table control>[<Index>]

Remark: the index of the current line can be known by the TableSelect function.. For example:
// Retrieve the contents of row 10 in the TVT_CUSTOMER TreeView Table control
CurrentRow = TVT_CUSTOMER[10]
// Name of the selected customer
CustomerName = COL_NAME[TableSelect(TVT_CUSTOMER)]
// Retrieve the contents of the current row in the TVT_CUSTOMER TreeView Table control
CurrentRow = TVT_CUSTOMER
Operations on the tree structure

Collapsing all the nodes of a TreeView Table control

To collapse all the nodes of a TreeView Table control, use TableCollapseAll. The syntax used is as follows:
TableCollapseAll(<TreeView Table control>)

Expanding all the nodes of a TreeView Table control

To expand all the nodes of a TreeView Table control, use TableExpandAll. The syntax used is as follows:
TableExpandAll(<TreeView Table control>)
WINDEV Note: If the TreeView Table control uses dynamic population filling of sublevels via the AddChildDelayed property, the sublevel filling procedure will be executed for each new element unrolled..

Getting the number of the collapsed/expanded row

To get the number of the row that is expanded or collapsed, simply use the "Collapse/Expand a node" event in the TreeView Table control:
// Which row is used?
Info(TVT_TreeViewTable[TVT_TreeViewTable])

Defining the state of new rows

You can define the state of the next row that will be added to a TreeView Table control (collapsed or expanded). To do so, use the Collapsed property.
// The next added rows will be automatically collapsed
TVT_TreeViewTable.Collapsed = True

Getting and setting the images of the rows

To get and set the images of the rows in a TreeView Table control, use the following properties:
// Modify the images of rows in a TreeView Table control
TVT_TreeViewTable.ExpandedImage = "OpenFolder.gif"
TVT_TreeViewTable.CollapsedImage = "ClosedFolder.gif"
WINDEV

TreeView column with Check Box

A Check Box column can be defined as "TreeView column" in a TreeView Table control. In this case, the Check Box column can be used to manage the tree structure.
The Caption property of the row gets and sets the text displayed next to the check box. The Value property of the row gets and sets the value of the check box.

Getting the parent or children of an element

The following functions can be used to find out the parent or the children of an element:
  • TableGiveParent: Returns the "parent" of an element, i.e. the element of the higher level.
  • TableGiveChild: Returns the "children" of an element, i.e. the elements of the lower level.
Properties specific to TreeView Table controls
The following properties allow you to define the characteristics of TreeView Table controls.
AddChildDelayedDefines the procedure that will be called to populate a branch dynamically.
CollapsedGets and sets the state (collapsed or expanded) of new rows added to a TreeView Table control.
MergeDetermines whether the cells (or column headings) of a TreeView Table control are merged and merges them if necessary.
ExpandedImageGets and sets the default image of an expanded row in a TreeView Table control.
CollapsedImageGets and sets the default image of a collapsed row in a TreeView Table control.
MultiselectionGets and sets the selection mode in a TreeView Table control.
TotalNbChildrenReturns the total number of children for a branch in a TreeView Table control.
SortOptionGets and sets the sort options of a column in a TreeView Table control.
LeftIndentGets and sets the space to the left of the text in the columns of a TreeView Table control.
BrowsedItemGets and sets the item used to loop through TreeView Table controls automatically.
SizeGets and sets the number of columns in a TreeView Table control.
TotalsEnabledDetermines how automatic calculations are performed in a TreeView Table control and disables or forces automatic calculations in the control.

For a complete list of the WLanguage properties that can be used:
Minimum version required
  • Version 11
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/30/2024

Send a report | Local help