ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

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
  • Managing calculated columns
  • Operations on the 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
  • Getting the parent or children of an element
  • Properties specific to TreeView Table controls
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
This page explains how to program TreeView Table controls. There are multiple WLanguage functions to programmatically handle 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, use the following functions:
If a new row was added into a TreeView Table control by <Table>.Add, <Table>.Insert, <Table>.AddLine, <TreeView Table>.AddChild, <Table>.InsertLine or <TreeView Table>.InsertChild, the New property is set to True (otherwise, it is set to False).
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:

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 <Table>.Modify or <Table>.ModifyLine to modify the contents of the current row or a specific row.
      For example:
      TVT_CUSTOMER.Modify("MOORE" + TAB + "Vince" + TAB + "Miami")

      Remark: You can also use the name of the TreeView Table control directly:
      // Modify the current row
      TVT_CUSTOMER = "MOORE" + TAB + "Vince" + TAB + "Miami"
      // Modify the COL_DAY coloumn of row 3
      COL_DAY.Modify("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).

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_PBT: calculated column
// COL_UPBT and COL_QTY: columns linked to memory areas
COL_PBT = COL_UPBT * COL_QTY
Operations on the rows and cells

Deleting a row

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

    If the index is specified, <Table>.Delete 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 for <TreeView Table>.DeleteChild is as follows:
    <TreeView Table control>.DeleteChild(<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 <Table>.SelectPlus.
The syntax used is as follows:
<TreeView Table control>.SelectPlus([, <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 contents of the 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: <Table>.Select returns the index of the current row. 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[TVT_CUSTOMER.Select()]
// 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 <Table>.CollapseAll. The syntax is as follows:
<TreeView Table control>.CollapseAll()

Expanding all the nodes of a TreeView Table control

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

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"

Getting the parent or children of an element

The following functions can be used to get the parent or children of an element:
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 23
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/29/2022

Send a report | Local help