|
|
|
|
|
- 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
Manipulating TreeView Table controls programmatically
This page explains how to program TreeView Table controls. There are multiple WLanguage functions to programmatically manipulate TreeView Table controls.
Initializing a TreeView Table control To programmatically populate a TreeView Table control, can use the following functions: 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 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:
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 = COL_UPBT * COL_QTY
Operations on rows and cells Deleting a row - 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 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: 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>) 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.
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 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. | | AddChildDelayed | Defines the procedure that will be called to populate a branch dynamically. | Collapsed | Gets and sets the state (collapsed or expanded) of new rows added to a TreeView Table control. | Merge | Determines whether the cells (or column headings) of a TreeView Table control are merged and merges them if necessary. | ExpandedImage | Gets and sets the default image of an expanded row in a TreeView Table control. | CollapsedImage | Gets and sets the default image of a collapsed row in a TreeView Table control. | Multiselection | Gets and sets the selection mode in a TreeView Table control. | TotalNbChildren | Returns the total number of children for a branch in a TreeView Table control. | SortOption | Gets and sets the sort options of a column in a TreeView Table control. | LeftIndent | Gets and sets the space to the left of the text in the columns of a TreeView Table control. | BrowsedItem | Gets and sets the item used to loop through TreeView Table controls automatically. | Size | Gets and sets the number of columns in a TreeView Table control. | TotalsEnabled | Determines 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:
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|