PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • 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 the rows and cells
  • Deleting a row
  • Selecting a row
  • Retrieving the contents of a row or cell
  • Value of the cell in the current row
  • Value of a cell in a specific row
  • Contents of the current row
  • Contents 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
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).
WINDEV Remark: To dynamically populate a TreeView Table control, you can use the AddChildDelayed property on the rows of the control.
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 Remark: If the "Cascading 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 <Table>.Add or <Table>.AddLine.

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 column name (like for an edit control) to modify the column content. 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 described 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 contents 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

Contents of the current row

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

Contents 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()
WINDEV Remark: If the AddChildDelayed property is used to dynamically populate the sub-levels in a TreeView Table control, the sub-level population procedure will be executed for each new element expanded on the client site.

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 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