Color scheme: Dark
You are here: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » WKL Forms Object Library API reference » WklTreeView

WklTreeView

WklTreeView class

Signature

Dim myWklTreeView As WklTreeView
Set myWklTreeView = Me!ControlName.Object

Summary

A data-bound tree for Access forms: one node per record of a table, query or SQL statement.

Parameters

None

Remarks

The tree is bound through four properties: RecordSource names the records, KeyField the unique key of a node, ParentField the key of its parent, and TextField the displayed text. A record whose parent key does not exist in the source (Null, 0, or any unknown value) is a root. Optional fields add a sort order, symbols, tooltips, check marks, a text color and bold text per node.

Keys are passed as Variant in the type of the key field (Long for an AutoNumber, String for a text key). With a composite key - KeyField naming several fields - a key is an array with one value per key field, Array(4711, 2), in parameters, return values and events alike. Every member that takes a Key raises wkeKeyNotFound when no node has that key.

Events report actions of the user. Changes made by code (for example setting SelectedKey or calling MoveNode) raise no events, like AfterUpdate of an Access control.

Events of an ActiveX control reach VBA only through an event procedure in the form's module (or a WithEvents variable in a class module); Access offers no event property with an expression such as =Funktion() for them. A form without a module receives none of the control's events. What works without a module: the control's own built-in behavior (editing, deleting, menus, export), properties set in design view, and code in another module that reads the control's state (SelectedKey, SelectedKeys) when the user runs an Access command, for example from a ribbon button or an Access shortcut menu. WklTreeList, WklGantt and WklGrid also show the entries of an Access shortcut menu bar in their own shortcut menu (ShortcutMenuBar); the entries call functions of a standard module.

With AutoSave (the default), renames, moves, additions, copies, deletions and check marks made by the user or by code are written into the record source right away, each operation in one transaction. For operations of the user, BeforeUpdate can cancel the operation and roll it back.

The events appear in the code window's object list under the control's name.

An ActiveX control: inserted into a form in design view (Form Design › Controls › ActiveX Controls); reports are not supported. VBA reaches it through the Object property of the control, where ControlName is the name of the control on the form.

MemberKindSummary
`SelectedKey`PropertyGets or sets the key of the selected node.
`RecordSource`PropertyGets or sets the table, query or SQL statement that delivers one record per node.
`KeyField`PropertyGets or sets the field with the unique key of a node.
`ParentField`PropertyGets or sets the field with the key of the node's parent.
`TextField`PropertyGets or sets the field with the displayed text of a node.
`SortField`PropertyGets or sets the field that orders sibling nodes.
`ImageField`PropertyGets or sets the field with the symbol name of a node.
`LazyLoad`PropertyGets or sets whether the children of a node are loaded only when it is expanded.
`ExpandLevel`PropertyGets or sets how many levels are expanded after loading.
`CheckBoxes`PropertyGets or sets whether a check box is shown in front of each node.
`ShowLines`PropertyGets or sets whether lines connect parent and child nodes.
`ShowRootLines`PropertyGets or sets whether lines and expand buttons are also drawn in front of the roots.
`FullRowSelect`PropertyGets or sets whether the selection covers the full width of the row.
`HideSelection`PropertyGets or sets whether the selection is hidden while another control has the focus.
`BackColor`PropertyGets or sets the background color.
`ForeColor`PropertyGets or sets the text color.
`FontName`PropertyGets or sets the font name.
`FontSize`PropertyGets or sets the font size in points.
`DefaultImage`PropertyGets or sets the symbol of nodes without a symbol of their own.
`SelectedText`PropertyReturns the text of the selected node.
`NodeCount`PropertyReturns the number of loaded nodes.
`Checked`PropertyGets or sets the check mark of a node.
`CheckedKeys`PropertyReturns the keys of all checked nodes.
`Recordset`PropertyGets or sets the DAO or ADO recordset the nodes were loaded from.
`Requery`MethodReads the record source again.
`Expand`MethodExpands a node.
`Collapse`MethodCollapses a node.
`ExpandAll`MethodExpands every node.
`CollapseAll`MethodCollapses every node.
`EnsureVisible`MethodExpands the ancestors of a node and scrolls it into view.
`SortOrder`PropertyGets or sets the order of sibling nodes.
`LabelEdit`PropertyGets or sets whether the user can rename nodes.
`AllowDragDrop`PropertyGets or sets whether the user can move nodes with the mouse.
`AutoSave`PropertyGets or sets whether changes are written into the record source right away.
`NodeText`PropertyGets or sets the text of a node.
`MoveNode`MethodMoves a node to a new place.
`StartLabelEdit`MethodStarts renaming a node in form view, for example from a custom menu item.
`SaveToFile`MethodSaves the nodes and their state (expanded nodes, selection, check marks) to a file.
`LoadFromFile`MethodLoads a file written by SaveToFile.
`SaveToStream`MethodWrites the nodes and their state to an open ADODB.Stream.
`LoadFromStream`MethodReads the nodes and their state from an open ADODB.Stream.
`MultiSelect`PropertyGets or sets whether several nodes can be selected.
`SelectedKeys`PropertyGets or sets the keys of all selected nodes.
`ContextMenu`PropertyGets or sets whether the built-in context menu opens on the right mouse button.
`AllowAdditions`PropertyGets or sets whether the user can add nodes.
`AllowDeletions`PropertyGets or sets whether the user can delete nodes.
`AddNode`MethodAdds a node and returns its key.
`CopyNode`MethodCopies a node with its subtree and returns the key of the copy.
`DeleteNode`MethodDeletes a node with its subtree, without confirmation.
`PathSeparator`PropertyGets or sets the separator of text paths.
`FullPath`PropertyReturns the text path of a node.
`SelectNode`MethodSelects the node a path finds and returns its key.
`FindNodes`MethodReturns the keys of all nodes a JPath expression finds.
`NodeExists`MethodTells whether a path finds a node.
`SaveToString`MethodReturns the nodes and their state as text.
`LoadFromString`MethodLoads the nodes and their state from a text written by SaveToString.
`AsJSON`PropertyGets or sets the nodes and their state as a WKL Office JSON document.
`BeginUpdate`MethodSuspends drawing until the matching EndUpdate.
`EndUpdate`MethodEnds a BeginUpdate.
`EventProcedures`PropertyLists the events that have an event procedure in the form module.
`ToolTipField`PropertyGets or sets the field with the tooltip of a node.
`NodeToolTip`PropertyReturns the tooltip of a node.
`CheckedField`PropertyGets or sets the Yes/No field with the check mark of a node.
`CheckMode`PropertyGets or sets how check boxes behave.
`NodeCheckState`PropertyReturns the displayed state of a node's check box.
`ForeColorField`PropertyGets or sets the field with the text color of a node.
`BoldField`PropertyGets or sets the Yes/No field that shows a node's text in bold.
`AllowSearch`PropertyGets or sets whether Ctrl+F opens the search bar in form view.
`SearchText`PropertyGets or sets the search text.
`FindNext`MethodSelects the next match of SearchText and returns its key.
`SearchCount`PropertyReturns the number of matches of SearchText.
`Filter`PropertyGets or sets a filter that limits the visible nodes.
`AddMenuItem`MethodAdds a custom item to the context menu.
`RemoveMenuItem`MethodRemoves the custom menu item with a tag.
`ClearMenuItems`MethodRemoves all custom menu items.
`Layout`PropertyGets or sets the view state as text: expanded nodes and selection, without the nodes.
`FormatEvents`PropertyGets or sets whether NodeFormat (and CellFormat of WklTreeList) is raised.
`LivePreview`PropertyGets or sets whether design view shows the real data.
`LinkChildFields`PropertyGets or sets the fields that link the records to a master record, as on an Access subform.
`LinkMasterFields`PropertyGets or sets the fields or controls of the master that hold the values for LinkChildFields.
`MasterValue`PropertyGets or sets the value Access writes into the control on every record change of the form when ControlSource is set.
`MasterValues`PropertyGets or sets the master values the records are limited to.
`MasterRecordset`PropertyGets or sets a DAO or ADO recordset whose current record is the master.
`SyncMaster`MethodReads the master values again and reloads the records when they changed.
`KeyCriteria`MethodReturns the WHERE condition that finds the record of a key.
`MasterFilterMode`PropertyGets or sets how a linked tree selects the records of the master record.
`ColorScheme`PropertyGets or sets the color scheme the control draws in.
`AllowFileDrop`PropertyGets or sets whether files and folders dragged from Windows Explorer can be dropped on the control.
EventSummary
`NodeSelect`Occurs when the user selects a node.
`NodeExpand`Occurs after a node is expanded.
`NodeCollapse`Occurs after a node is collapsed.
`NodeCheck`Occurs after the user toggles a check box.
`NodeDblClick`Occurs when the user double-clicks a node.
`BeforeNodeSelect`Occurs before a node is selected.
`BeforeExpand`Occurs before a node is expanded.
`BeforeCollapse`Occurs before a node is collapsed.
`BeforeNodeCheck`Occurs before a check box is toggled.
`NodeClick`Occurs when the user clicks a node with the left mouse button.
`NodeRightClick`Occurs when the user right-clicks a node.
`BeforeLabelEdit`Occurs before the user starts renaming a node.
`AfterLabelEdit`Occurs after the user renamed a node, before the new text is saved.
`NodeDragStart`Occurs when the user starts dragging a node.
`NodeDragOver`Occurs when a dragged node moves over a new target.
`NodeDrop`Occurs when a node is moved or copied, before the change is saved.
`AfterNodeDrop`Occurs after a node was moved or copied and saved.
`CompareNodes`Occurs when two sibling nodes are compared with SortOrder = wsoCustom.
`AfterRequery`Occurs after the nodes were loaded again.
`DataError`Occurs when loading or saving fails.
`KeyDown`Occurs when a key is pressed while the control has the focus.
`KeyPress`Occurs when a character is typed.
`KeyUp`Occurs when a key is released.
`MouseDown`Occurs when a mouse button is pressed over the control.
`MouseUp`Occurs when a mouse button is released over the control.
`MouseMove`Occurs when the mouse moves over the control.
`MouseWheel`Occurs when the mouse wheel turns over the control.
`SelectionChange`Occurs when the user changes the multiple selection (SelectedKeys).
`BeforeNodeCopy`Occurs before a node is copied.
`BeforeNodeAdd`Occurs before the user adds a node.
`AfterNodeAdd`Occurs after a node was added and saved.
`BeforeDelete`Occurs before the user deletes a node.
`AfterDelete`Occurs after a node was deleted with its subtree.
`BeforeUpdate`Occurs before each write into the record source caused by an action of the user.
`AfterUpdate`Occurs after each write into the record source caused by an action of the user.
`NodeFormat`Occurs before a node is shown in form view, to format it.
`MenuItemClick`Occurs when the user clicks a custom menu item.
`BeforeMasterChange`Occurs before the tree changes to the records of another master record.
`AfterMasterChange`Occurs after the tree was loaded with the records of another master record.
`FileDragOver`Occurs when files from Windows Explorer are dragged over a new target (AllowFileDrop).
`FileDrop`Occurs when files from Windows Explorer were dropped (AllowFileDrop).

Code example

Private Sub Form_Load()
    With Me!Tree1.Object
        .RecordSource = "tblCategories"
        .KeyField = "CategoryID": .ParentField = "ParentID": .TextField = "Name"
        .ExpandLevel = 1
    End With
End Sub
 
Private Sub Tree1_NodeSelect(ByVal Key As Variant)
    Me.Details.Form.Filter = "CategoryID = " & Key
    Me.Details.Form.FilterOn = True
End Sub

Inheritance

None

SelectedKey property

Signature

Property Get SelectedKey() As Variant
Property Let SelectedKey(RHS As Variant)

Summary

Gets or sets the key of the selected node.

Parameters

None

Property value: Variant – The key of the selected node, or Null when no node is selected.

Remarks

Setting a key selects that node, expands its ancestors and scrolls it into view; setting Null clears the selection. With MultiSelect, SelectedKey is the focused node of the selection; SelectedKeys returns all of them. Setting SelectedKey by code makes that node the whole selection, as setting the current record of an Access form does (before type library 1.28 the nodes the user had selected stayed selected, so Delete acted on them).

Default member: it can be left out, as in myWklTreeView(...) for myWklTreeView.SelectedKey(...). Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

RecordSource property

Signature

Property Get RecordSource() As String
Property Let RecordSource(RHS As String)

Summary

Gets or sets the table, query or SQL statement that delivers one record per node.

Parameters

None

Property value: String – A table name, a query name or an SQL statement. Queries may contain form references.

Remarks

The name is RecordSource, not RowSource: an ActiveX property named RowSource makes the Access property sheet crash. Changing the value reloads the tree.

The control reads one record source for all levels; there is no record source per level. A tree whose parents and children live in different tables needs one query that returns both, usually a UNION query, with a key that is unique across both parts. Access cannot update a UNION query: set AllowEditing to False (and AllowAdditions, AllowDeletions), or load the tree through Recordset, so the user is not offered changes that cannot be saved (see AutoSave).

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

KeyField property

Signature

Property Get KeyField() As String
Property Let KeyField(RHS As String)

Summary

Gets or sets the field with the unique key of a node.

Parameters

None

Property value: String – A field name of the record source, or several separated by semicolons for a composite key (OrderID;LineNo).

Remarks

A duplicate key raises wkeDuplicateKey when the tree loads. With a composite key, keys are arrays in VBA (Array(4711, 2)); new keys are proposed by continuing the last part within the leading parts, because a composite key has no AutoNumber.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

ParentField property

Signature

Property Get ParentField() As String
Property Let ParentField(RHS As String)

Summary

Gets or sets the field with the key of the node's parent.

Parameters

None

Property value: String – A field name of the record source; for a composite key as many fields as KeyField, in the same order (OrderID;ParentLineNo).

Remarks

A record whose parent key does not exist is a root; with a composite key also a record whose parent key has a Null part. A different number of fields than KeyField raises wkeInvalidValue. A cycle in the parent keys raises wkeCycle. WklTreeList with GroupFields accepts an empty value.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

TextField property

Signature

Property Get TextField() As String
Property Let TextField(RHS As String)

Summary

Gets or sets the field with the displayed text of a node.

Parameters

None

Property value: String – A field name of the record source.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

SortField property

Signature

Property Get SortField() As String
Property Let SortField(RHS As String)

Summary

Gets or sets the field that orders sibling nodes.

Parameters

None

Property value: String – A field name, or an empty string to order siblings by their text.

Remarks

SortOrder decides the direction. With a sort field, siblings are ordered by it and then by text.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

ImageField property

Signature

Property Get ImageField() As String
Property Let ImageField(RHS As String)

Summary

Gets or sets the field with the symbol name of a node.

Parameters

None

Property value: String – A field name, or an empty string for no symbols from the data.

Remarks

A symbol is an image of the database's image gallery, a built-in name, or a file path. Nodes without a symbol use DefaultImage. The built-in names are Windows icons under an English name that stays the same in every language: Application, Delete, Document, Drive, Error, Folder, FolderOpen, Help, Info, Key, Link, Lock, Network, NetworkDrive, Printer, RecycleBin, Search, Server, Settings, Shield, Users, Warning, World. The German names of releases up to 1.53 (Ordner, Dokument, Warnung …) keep working, so data written with them needs no change. The designer shows the built-in symbols under their name in the user interface language and copies the English name.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

LazyLoad property

Signature

Property Get LazyLoad() As Boolean
Property Let LazyLoad(RHS As Boolean)

Summary

Gets or sets whether the children of a node are loaded only when it is expanded.

Parameters

None

Property value: Boolean – True (default) to load on expand, False to load all records at once.

Remarks

Lazy loading reads the roots first and each level on demand, which suits large or linked tables. ExpandAll, FindNodes and a search in loaded nodes load the whole tree. Grouped records (WklTreeList.GroupFields) are always loaded completely.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

ExpandLevel property

Signature

Property Get ExpandLevel() As Long
Property Let ExpandLevel(RHS As Long)

Summary

Gets or sets how many levels are expanded after loading.

Parameters

None

Property value: Long – The number of levels; 0 (default) shows only the roots.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

CheckBoxes property

Signature

Property Get CheckBoxes() As Boolean
Property Let CheckBoxes(RHS As Boolean)

Summary

Gets or sets whether a check box is shown in front of each node.

Parameters

None

Property value: Boolean – True to show check boxes; False (default) to hide them.

Remarks

CheckedField binds the check marks to a Yes/No field; CheckMode makes them recursive.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

ShowLines property

Signature

Property Get ShowLines() As Boolean
Property Let ShowLines(RHS As Boolean)

Summary

Gets or sets whether lines connect parent and child nodes.

Parameters

None

Property value: Boolean – True (default) to draw the lines.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

ShowRootLines property

Signature

Property Get ShowRootLines() As Boolean
Property Let ShowRootLines(RHS As Boolean)

Summary

Gets or sets whether lines and expand buttons are also drawn in front of the roots.

Parameters

None

Property value: Boolean – True (default) to draw them.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

FullRowSelect property

Signature

Property Get FullRowSelect() As Boolean
Property Let FullRowSelect(RHS As Boolean)

Summary

Gets or sets whether the selection covers the full width of the row.

Parameters

None

Property value: Boolean – True to select the full row; False (default) to select the text only.

Remarks

Takes effect only when ShowLines is False, as in the Windows tree view.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

HideSelection property

Signature

Property Get HideSelection() As Boolean
Property Let HideSelection(RHS As Boolean)

Summary

Gets or sets whether the selection is hidden while another control has the focus.

Parameters

None

Property value: Boolean – True (default) to hide it.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

BackColor property

Signature

Property Get BackColor() As OLE_COLOR
Property Let BackColor(RHS As OLE_COLOR)

Summary

Gets or sets the background color.

Parameters

None

Property value: OLE_COLOR – A color number as in Access; system colors from &H80000000 on. Default: the Windows window color.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

ForeColor property

Signature

Property Get ForeColor() As OLE_COLOR
Property Let ForeColor(RHS As OLE_COLOR)

Summary

Gets or sets the text color.

Parameters

None

Property value: OLE_COLOR – A color number as in Access; system colors from &H80000000 on. Default: the Windows window text color.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

FontName property

Signature

Property Get FontName() As String
Property Let FontName(RHS As String)

Summary

Gets or sets the font name.

Parameters

None

Property value: String – The name of an installed font. Default: Segoe UI.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

FontSize property

Signature

Property Get FontSize() As Long
Property Let FontSize(RHS As Long)

Summary

Gets or sets the font size in points.

Parameters

None

Property value: Long – The size in points. Default: 9.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

DefaultImage property

Signature

Property Get DefaultImage() As String
Property Let DefaultImage(RHS As String)

Summary

Gets or sets the symbol of nodes without a symbol of their own.

Parameters

None

Property value: String – A symbol name as for ImageField, or an empty string (default) for no symbol.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

SelectedText property

Signature

Property Get SelectedText() As Variant

Summary

Returns the text of the selected node.

Parameters

None

Property value: Variant – The text, or Null when no node is selected.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

NodeCount property

Signature

Property Get NodeCount() As Long

Summary

Returns the number of loaded nodes.

Parameters

None

Property value: Long – The number of nodes loaded so far; with LazyLoad it grows as nodes are expanded.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

Checked property

Signature

Property Get Checked(ByVal Key As Variant) As Boolean
Property Let Checked(ByVal Key As Variant, RHS As Boolean)

Summary

Gets or sets the check mark of a node.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.

Property value: Boolean – True when the node's check box is checked.

Remarks

Setting the value checks or clears the node; with CheckedField and AutoSave it is written into the record source, and with CheckMode = wcmRecursive it applies to the whole subtree.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

CheckedKeys property

Signature

Property Get CheckedKeys() As Variant

Summary

Returns the keys of all checked nodes.

Parameters

None

Property value: Variant – A Variant array of keys; an empty array when no node is checked.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

Recordset property

Signature

Property Get Recordset() As Object
Property Set Recordset(RHS As Object)

Summary

Gets or sets the DAO or ADO recordset the nodes were loaded from.

Parameters

None

Property value: Object – The recordset, or Nothing when the tree is bound through RecordSource.

Remarks

Assign with Set: all records are loaded at once from the recordset. A tree loaded this way does not write back with AutoSave, because it has no record source to write to.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

Requery method

Signature

Sub Requery()

Summary

Reads the record source again.

Parameters

None

Remarks

The selection and the expanded nodes are kept as far as they still exist. Raises AfterRequery.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

Expand method

Signature

Sub Expand(ByVal Key As Variant)

Summary

Expands a node.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.

Remarks

With LazyLoad, the children are loaded first.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

Collapse method

Signature

Sub Collapse(ByVal Key As Variant)

Summary

Collapses a node.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.

Remarks

None

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

ExpandAll method

Signature

Sub ExpandAll()

Summary

Expands every node.

Parameters

None

Remarks

With LazyLoad, the whole tree is loaded first.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

CollapseAll method

Signature

Sub CollapseAll()

Summary

Collapses every node.

Parameters

None

Remarks

None

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

EnsureVisible method

Signature

Sub EnsureVisible(ByVal Key As Variant)

Summary

Expands the ancestors of a node and scrolls it into view.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.

Remarks

None

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

SortOrder property

Signature

Property Get SortOrder() As WklSortOrder
Property Let SortOrder(RHS As WklSortOrder)

Summary

Gets or sets the order of sibling nodes.

Parameters

None

Property value: `WklSortOrder` – A `WklSortOrder` constant. Default: wsoAscending.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

LabelEdit property

Signature

Property Get LabelEdit() As Boolean
Property Let LabelEdit(RHS As Boolean)

Summary

Gets or sets whether the user can rename nodes.

Parameters

None

Property value: Boolean – True to allow renaming (F2, or a click on the selected node); False (default) to prevent it.

Remarks

A rename raises BeforeLabelEdit and AfterLabelEdit; with AutoSave the new text is written into TextField.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

AllowDragDrop property

Signature

Property Get AllowDragDrop() As Boolean
Property Let AllowDragDrop(RHS As Boolean)

Summary

Gets or sets whether the user can move nodes with the mouse.

Parameters

None

Property value: Boolean – True to allow dragging; False (default) to prevent it.

Remarks

Dragging moves a node; with Ctrl held down it copies the node with its subtree. The same operations are available with Ctrl+X, Ctrl+C, Ctrl+V and Alt+Arrow keys. Only moves within the same control are supported.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

AutoSave property

Signature

Property Get AutoSave() As Boolean
Property Let AutoSave(RHS As Boolean)

Summary

Gets or sets whether changes are written into the record source right away.

Parameters

None

Property value: Boolean – True (default) to write every change; False to change only the display.

Remarks

Each operation is written in one transaction; BeforeUpdate can cancel it and roll back what was already written. A tree loaded from a Recordset or a file never writes.

The control does not check beforehand whether the record source can be updated. When Access refuses to write - a query that cannot be updated, a validation rule, a locked record - the transaction is rolled back, the tree is reloaded, and DataError occurs, followed by a message box with its text unless DataError sets Response to acDataErrContinue. For a source that cannot be updated, switch editing off instead (AllowEditing, AllowAdditions, AllowDeletions).

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

NodeText property

Signature

Property Get NodeText(ByVal Key As Variant) As String
Property Let NodeText(ByVal Key As Variant, RHS As String)

Summary

Gets or sets the text of a node.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.

Property value: String – The displayed text.

Remarks

Setting the text renames the node; with AutoSave the new text is written into TextField.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

MoveNode method

Signature

Sub MoveNode(ByVal Key As Variant, ByVal TargetKey As Variant, Optional ByVal Position As WklDropPosition = wdpInside)

Summary

Moves a node to a new place.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node to move.
TargetKeyVariantNo–The key of the target node, or Null to move the node to the end of the roots.
Position`WklDropPosition`YeswdpInsideWhere the node goes relative to the target: inside it, before it or after it.

Remarks

With AutoSave, the new parent key (and the sort value, when SortField is set) is written into the record source. Moving a node below itself or one of its descendants raises wkeInvalidValue.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

StartLabelEdit method

Signature

Sub StartLabelEdit(ByVal Key As Variant)

Summary

Starts renaming a node in form view, for example from a custom menu item.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.

Remarks

None

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

SaveToFile method

Signature

Sub SaveToFile(ByVal Path As String, Optional ByVal Format As WklFileFormat = wffAuto)

Summary

Saves the nodes and their state (expanded nodes, selection, check marks) to a file.

Parameters

NameTypeOptionalDefaultDescription
PathStringNo–The file path.
Format`WklFileFormat`YeswffAutoThe file format; wffAuto writes XML for the extension .xml and JSON otherwise.

Remarks

Values keep their type (a Long key loads as Long) and are written independent of regional settings. A WklTreeList also writes the values of its columns with each node; LoadFromFile into an unbound list shows them again. Files without column values load with empty columns.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

LoadFromFile method

Signature

Sub LoadFromFile(ByVal Path As String, Optional ByVal Format As WklFileFormat = wffAuto)

Summary

Loads a file written by SaveToFile.

Parameters

NameTypeOptionalDefaultDescription
PathStringNo–The file path.
Format`WklFileFormat`YeswffAutoThe file format; wffAuto recognizes JSON and XML from the content.

Remarks

Without RecordSource, the file's nodes become an unbound tree. With RecordSource, only the state is applied (expanded nodes, selection, check marks) to the nodes of the source. An invalid file raises wkeInvalidValue.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

SaveToStream method

Signature

Sub SaveToStream(ByVal Stream As Object, Optional ByVal Format As WklFileFormat = wffJson)

Summary

Writes the nodes and their state to an open ADODB.Stream.

Parameters

NameTypeOptionalDefaultDescription
StreamObjectNo–An open text or binary ADODB.Stream; the text is written as UTF-8 at the current position.
Format`WklFileFormat`YeswffJsonThe format; default wffJson.

Remarks

None

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

LoadFromStream method

Signature

Sub LoadFromStream(ByVal Stream As Object, Optional ByVal Format As WklFileFormat = wffAuto)

Summary

Reads the nodes and their state from an open ADODB.Stream.

Parameters

NameTypeOptionalDefaultDescription
StreamObjectNo–An open ADODB.Stream, read from its current position.
Format`WklFileFormat`YeswffAutoThe format; wffAuto recognizes JSON and XML from the content.

Remarks

The rules of LoadFromFile apply.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

MultiSelect property

Signature

Property Get MultiSelect() As Boolean
Property Let MultiSelect(RHS As Boolean)

Summary

Gets or sets whether several nodes can be selected.

Parameters

None

Property value: Boolean – True to allow Ctrl+click and Shift+click; False (default) for a single selection.

Remarks

Dragging, copying and deleting act on all selected nodes.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

SelectedKeys property

Signature

Property Get SelectedKeys() As Variant
Property Let SelectedKeys(RHS As Variant)

Summary

Gets or sets the keys of all selected nodes.

Parameters

None

Property value: Variant – A Variant array of keys, in display order.

Remarks

Setting an array selects those nodes; setting an empty array clears the selection.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

ContextMenu property

Signature

Property Get ContextMenu() As Boolean
Property Let ContextMenu(RHS As Boolean)

Summary

Gets or sets whether the built-in context menu opens on the right mouse button.

Parameters

None

Property value: Boolean – True (default) to show it; False to show only the custom items of AddMenuItem.

Remarks

The built-in menu of WklTreeView (the menus of WklTreeList and WklGrid are described on their pages):

EntryShown or enabledKey shown
Aufklappen, Zuklappenenabled for a node with children that is collapsed or expanded→ / ←
Expand all child nodesenabled for a node with children*
Collapse allalways
New node here, New node belowAllowAdditionsIns / Ctrl+Ins
UmbenennenLabelEditF2
DeleteAllowDeletionsDel
Cut, Copy, PasteAllowDragDrop; Paste enabled after cutting or copyingCtrl+X / Ctrl+C / Ctrl+V
Nach oben, Nach untenAllowDragDrop; enabled when the node can moveAlt+↑ / Alt+↓
RefreshalwaysF5
SearchAllowSearchCtrl+F
custom entries (AddMenuItem)always, after a separator

With ContextMenu = False only the custom entries are shown. Before any menu opens, NodeRightClick occurs; setting its Cancel shows no menu at all, for example to show an Access shortcut menu instead. The menu key and Shift+F10 open the same menu at the selected node, without NodeRightClick.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

AllowAdditions property

Signature

Property Get AllowAdditions() As Boolean
Property Let AllowAdditions(RHS As Boolean)

Summary

Gets or sets whether the user can add nodes.

Parameters

None

Property value: Boolean – True to allow Insert (same level) and Ctrl+Insert (below) and the menu items; False (default) to prevent it.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

AllowDeletions property

Signature

Property Get AllowDeletions() As Boolean
Property Let AllowDeletions(RHS As Boolean)

Summary

Gets or sets whether the user can delete nodes.

Parameters

None

Property value: Boolean – True to allow Delete and the menu item; False (default) to prevent it.

Remarks

A node is deleted with its subtree after a confirmation, which BeforeDelete can suppress.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

AddNode method

Signature

Function AddNode(ByVal TargetKey As Variant, ByVal Text As String, Optional ByVal Position As WklDropPosition = wdpInside) As Variant

Summary

Adds a node and returns its key.

Parameters

NameTypeOptionalDefaultDescription
TargetKeyVariantNo–The key of the target node, or Null to add a new root.
TextStringNo–The text of the new node.
Position`WklDropPosition`YeswdpInsideWhere the node goes relative to the target: inside it (default), before it or after it.

Return value: Variant – The key of the new node.

Remarks

With AutoSave, a record is added to the record source; an AutoNumber key is returned as assigned by Access.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

CopyNode method

Signature

Function CopyNode(ByVal Key As Variant, ByVal TargetKey As Variant, Optional ByVal Position As WklDropPosition = wdpInside) As Variant

Summary

Copies a node with its subtree and returns the key of the copy.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node to copy.
TargetKeyVariantNo–The key of the target node, or Null to copy to the end of the roots.
Position`WklDropPosition`YeswdpInsideWhere the copy goes relative to the target: inside it (default), before it or after it.

Return value: Variant – The key of the copy.

Remarks

With AutoSave, the records are copied in the record source. Attachment and multi-valued fields are not copied.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

DeleteNode method

Signature

Sub DeleteNode(ByVal Key As Variant)

Summary

Deletes a node with its subtree, without confirmation.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.

Remarks

With AutoSave, the records are deleted from the record source.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

PathSeparator property

Signature

Property Get PathSeparator() As String
Property Let PathSeparator(RHS As String)

Summary

Gets or sets the separator of text paths.

Parameters

None

Property value: String – The separator used by FullPath, SelectNode and NodeExists. Default: a backslash, as in the VB6 TreeView.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

FullPath property

Signature

Property Get FullPath(ByVal Key As Variant) As String

Summary

Returns the text path of a node.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.

Property value: String – The texts from the root down to the node, separated by PathSeparator.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

SelectNode method

Signature

Function SelectNode(ByVal Path As String) As Variant

Summary

Selects the node a path finds and returns its key.

Parameters

NameTypeOptionalDefaultDescription
PathStringNo–A text path (texts separated by PathSeparator) or a JPath expression starting with $.

Return value: Variant – The key of the selected node.

Remarks

Texts in a text path are compared without case. With LazyLoad, only the levels along the path are loaded. A JPath expression selects its first match. A path that finds no node raises wkeKeyNotFound; use NodeExists to test first.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

FindNodes method

Signature

Function FindNodes(ByVal JPath As String) As Variant

Summary

Returns the keys of all nodes a JPath expression finds.

Parameters

NameTypeOptionalDefaultDescription
JPathStringNo–A JPath expression, as in WKL Office JSON.

Return value: Variant – A Variant array of keys; an empty array when nothing matches.

Remarks

The expression runs over a JSON view of the tree in which every node has the members Key, Text, ParentKey, Image, SortValue, Checked, Level and Nodes (its children). With LazyLoad, the whole tree is loaded first.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

NodeExists method

Signature

Function NodeExists(ByVal Path As String) As Boolean

Summary

Tells whether a path finds a node.

Parameters

NameTypeOptionalDefaultDescription
PathStringNo–A text path or a JPath expression starting with $.

Return value: Boolean – True when a node is found.

Remarks

Never raises an error.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

SaveToString method

Signature

Function SaveToString(Optional ByVal Format As WklFileFormat = wffJson) As String

Summary

Returns the nodes and their state as text.

Parameters

NameTypeOptionalDefaultDescription
Format`WklFileFormat`YeswffJsonThe format; default wffJson.

Return value: String – The same text SaveToFile writes.

Remarks

None

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

LoadFromString method

Signature

Sub LoadFromString(ByVal Text As String, Optional ByVal Format As WklFileFormat = wffAuto)

Summary

Loads the nodes and their state from a text written by SaveToString.

Parameters

NameTypeOptionalDefaultDescription
TextStringNo–The text.
Format`WklFileFormat`YeswffAutoThe format; wffAuto recognizes JSON and XML from the content.

Remarks

The rules of LoadFromFile apply.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

AsJSON property

Signature

Property Get AsJSON() As Object
Property Set AsJSON(RHS As Object)

Summary

Gets or sets the nodes and their state as a WKL Office JSON document.

Parameters

None

Property value: Object – A JDoc; its Json property holds the text.

Remarks

Requires WKL Office JSON to be registered. Assigning a JDoc with Set loads it under the rules of LoadFromFile.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

BeginUpdate method

Signature

Sub BeginUpdate()

Summary

Suspends drawing until the matching EndUpdate.

Parameters

None

Remarks

Use it around many changes made by code. Calls can be nested.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

EndUpdate method

Signature

Sub EndUpdate()

Summary

Ends a BeginUpdate.

Parameters

None

Remarks

The last EndUpdate of a nesting redraws the tree once.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

EventProcedures property

Signature

Property Get EventProcedures() As String
Property Let EventProcedures(RHS As String)

Summary

Lists the events that have an event procedure in the form module.

Parameters

None

Property value: String – The event names, separated by semicolons. Writing is ignored.

Remarks

Access never lists the events of an ActiveX control on the property sheet's Event tab. This row of the Other tab is the way to them: its [...] button opens the Events page, which creates or opens the event procedures.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

ToolTipField property

Signature

Property Get ToolTipField() As String
Property Let ToolTipField(RHS As String)

Summary

Gets or sets the field with the tooltip of a node.

Parameters

None

Property value: String – A field name, or an empty string for no tooltips; for example a description when TextField holds a number.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

NodeToolTip property

Signature

Property Get NodeToolTip(ByVal Key As Variant) As String

Summary

Returns the tooltip of a node.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.

Property value: String – The value of ToolTipField for the node; an empty string without a tooltip.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

CheckedField property

Signature

Property Get CheckedField() As String
Property Let CheckedField(RHS As String)

Summary

Gets or sets the Yes/No field with the check mark of a node.

Parameters

None

Property value: String – A field name, or an empty string for check marks that are not stored.

Remarks

With AutoSave, toggling a check box writes the field.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

CheckMode property

Signature

Property Get CheckMode() As WklCheckMode
Property Let CheckMode(RHS As WklCheckMode)

Summary

Gets or sets how check boxes behave.

Parameters

None

Property value: `WklCheckMode` – A `WklCheckMode` constant. Default: wcmIndependent.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

NodeCheckState property

Signature

Property Get NodeCheckState(ByVal Key As Variant) As WklCheckState

Summary

Returns the displayed state of a node's check box.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.

Property value: `WklCheckState` – A `WklCheckState` constant; wcsMixed only with CheckMode = wcmRecursive.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

ForeColorField property

Signature

Property Get ForeColorField() As String
Property Let ForeColorField(RHS As String)

Summary

Gets or sets the field with the text color of a node.

Parameters

None

Property value: String – A field name with a color number, or an empty string to use ForeColor.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

BoldField property

Signature

Property Get BoldField() As String
Property Let BoldField(RHS As String)

Summary

Gets or sets the Yes/No field that shows a node's text in bold.

Parameters

None

Property value: String – A field name, or an empty string for regular text.

Remarks

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

AllowSearch property

Signature

Property Get AllowSearch() As Boolean
Property Let AllowSearch(RHS As Boolean)

Summary

Gets or sets whether Ctrl+F opens the search bar in form view.

Parameters

None

Property value: Boolean – True (default) to allow the search bar.

Remarks

The search bar searches the text of all nodes of the record source, loaded or not, and counts at most 1,000 matches. F3 and Shift+F3 move between matches; “Nur Treffer” filters to the matches.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

SearchText property

Signature

Property Get SearchText() As String
Property Let SearchText(RHS As String)

Summary

Gets or sets the search text.

Parameters

None

Property value: String – The text; nodes whose text contains it are highlighted. An empty string ends the search.

Remarks

Nodes that are not loaded yet count as matches too. SearchCount returns the number of matches, FindNext selects them.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

FindNext method

Signature

Function FindNext(Optional ByVal Backward As Boolean = False) As Variant

Summary

Selects the next match of SearchText and returns its key.

Parameters

NameTypeOptionalDefaultDescription
BackwardBooleanYesFalseTrue to select the previous match instead.

Return value: Variant – The key of the selected match, or Null when there is no match.

Remarks

None

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

SearchCount property

Signature

Property Get SearchCount() As Long

Summary

Returns the number of matches of SearchText.

Parameters

None

Property value: Long – The number of matches.

Remarks

Read-only.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

Filter property

Signature

Property Get Filter() As String
Property Let Filter(RHS As String)

Summary

Gets or sets a filter that limits the visible nodes.

Parameters

None

Property value: String – A WHERE condition of the record source (as Form.Filter), or a JPath expression starting with $ over the loaded nodes. An empty string shows all nodes.

Remarks

Matches stay visible together with their ancestors. A WHERE condition queries the record source each time it is set; for a pass-through query the whole query runs on the server. Every record that meets the condition is shown: for up to 1,000 matches the tree loads the path to each, for more it loads the whole tree once. In WklTreeList, FilterIncludesChildren shows the child nodes of a match as well, and the column filter applies in addition. Removing the filter restores the view from before.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

AddMenuItem method

Signature

Sub AddMenuItem(ByVal Caption As String, ByVal Tag As String, Optional ByVal BeginGroup As Boolean = False)

Summary

Adds a custom item to the context menu.

Parameters

NameTypeOptionalDefaultDescription
CaptionStringNo–The text of the item.
TagStringNo–The identifier passed to MenuItemClick.
BeginGroupBooleanYesFalseTrue to draw a separator before the item.

Remarks

Adding an item with a tag that exists replaces that item. In WklTreeList, WklGantt and WklGrid, MenuItemEnabled, MenuItemChecked, MenuItemGlyph, MenuItemShortcut and MenuItemParent change an item afterwards, and MenuPlacement sets where the items stand.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

RemoveMenuItem method

Signature

Sub RemoveMenuItem(ByVal Tag As String)

Summary

Removes the custom menu item with a tag.

Parameters

NameTypeOptionalDefaultDescription
TagStringNo–The tag given to AddMenuItem.

Remarks

None

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

ClearMenuItems method

Signature

Sub ClearMenuItems()

Summary

Removes all custom menu items.

Parameters

None

Remarks

None

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

Layout property

Signature

Property Get Layout() As String
Property Let Layout(RHS As String)

Summary

Gets or sets the view state as text: expanded nodes and selection, without the nodes.

Parameters

None

Property value: String – The layout text.

Remarks

Store the text between sessions (for example in a table or TempVars) and assign it back to restore the view.

In a WklTreeList and a WklGantt the text also holds the arrangement of the columns since type library 1.28 ("arrangement", as AutoSaveLayout remembers it); assigning a text without it - written by an older version, or with nothing changed - shows the columns as designed. Set before the control shows (in Form_Load), the text wins over the remembered arrangement; for storage of your own, switch AutoSaveLayout off. WklGantt adds its zoom, split position and first visible day.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

FormatEvents property

Signature

Property Get FormatEvents() As Boolean
Property Let FormatEvents(RHS As Boolean)

Summary

Gets or sets whether NodeFormat (and CellFormat of WklTreeList) is raised.

Parameters

None

Property value: Boolean – True to raise the events; False (default) to skip them.

Remarks

Access passes every event call to the form, handled or not, at a cost of about 3 ms per call; the formatting events run for every visible node or cell on every redraw. Switch this on only when the form handles the events. ForeColorField and BoldField do not need it.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

LivePreview property

Signature

Property Get LivePreview() As Boolean
Property Let LivePreview(RHS As Boolean)

Summary

Gets or sets whether design view shows the real data.

Parameters

None

Property value: Boolean – True to draw the records of the record source in design view; False (default) to draw sample nodes.

Remarks

With False, drawing the form in design view never queries the record source, so forms bound to pass-through queries or large linked tables open in design view without delay. Form view and the preview of the designer window always read the data. On a report the control shows a notice instead of data; reports are not supported. A tree linked to a master (LinkChildFields) shows in design view and in the designer preview the records of the form's first record, because design view has no current record.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

LinkChildFields property

Signature

Property Get LinkChildFields() As String
Property Let LinkChildFields(RHS As String)

Summary

Gets or sets the fields that link the records to a master record, as on an Access subform.

Parameters

None

Property value: String – Field names of the record source, separated by semicolons; empty (default) for a tree without master.

Remarks

With LinkChildFields set, the tree shows only the records whose link fields equal the master values (see LinkMasterFields, MasterValues and MasterRecordset). Without a master record - a new or empty master - the tree is empty and adding and copying are refused with wkeInvalidValue. New records get the master values in their link fields. The value is saved with the form.

Read/write.

Code example

With Me!List1.Object
    .LinkChildFields = "OrderID"
    .LinkMasterFields = "ID"
End With

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

LinkMasterFields property

Signature

Property Get LinkMasterFields() As String
Property Let LinkMasterFields(RHS As String)

Summary

Gets or sets the fields or controls of the master that hold the values for LinkChildFields.

Parameters

None

Property value: String – Names in the same order as LinkChildFields, separated by semicolons.

Remarks

The master is the form the control sits on, unless MasterRecordset or MasterValues is set. A name is looked up as a field of the form's recordset first and as a control of the form second, as LinkMasterFields of an Access subform. In form view the control checks the master record on idle (every 250 ms) and reloads when it changed; with ControlSource set, Access reports each change at once through MasterValue.

A name can also name another WKL control of the same form (WklGrid, WklTreeList, WklTreeView, WklGantt) as the master. Only the form the control sits on is searched: a control inside a subform cannot name a control of the main form; use MasterValues or MasterRecordset from code for that case. Grid1 stands for its key (every part of a composite key), Grid1.KundeID for a field of its selected record - the key, a column, or any other field of its record source. The control then follows the selection of that control without code: at once for a change made by code, after a short pause while the user moves through the records with the keyboard. With nothing selected there, or a group row, the control shows no records. Names of both kinds can be mixed. In design view with LivePreview, the first record of the master control's record source is the master.

The other way round, an Access subform follows a WKL control when its LinkMasterFields names the control (Grid1) and its LinkChildFields the field that holds the key: Access reads the selected key through the control's Value, and the control requeries such subforms when its selection changes, because Access does not do it by itself.

The value is saved with the form.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

MasterValue property

Signature

Property Get MasterValue() As Variant
Property Let MasterValue(RHS As Variant)

Summary

Gets or sets the value Access writes into the control on every record change of the form when ControlSource is set.

Parameters

None

Property value: Variant – The current value of the control's ControlSource.

Remarks

MasterValue is the bindable default property of the control for Access' data binding: set the control's ControlSource (property sheet, tab Data) to a link field such as ID, or to an expression over several fields, and Access writes the current value on every record change - also for filters and new records. The value is only the trigger: the master values are read from LinkMasterFields. Without ControlSource, the idle check does the same with a delay of up to 250 ms.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

MasterValues property

Signature

Property Get MasterValues() As Variant
Property Let MasterValues(RHS As Variant)

Summary

Gets or sets the master values the records are limited to.

Parameters

None

Property value: Variant – A value for one link field, or an array with one value per link field; Null when there is no master record.

Remarks

Reading returns the current master values, wherever they come from. Setting a value takes it from code and ignores the form and MasterRecordset until MasterValues is set to Null; this works in any container, also on Excel, Word and Outlook UserForms, which have no form recordset. Setting from code raises no events.

Read/write.

Code example

UserForm1.List1.MasterValues = Array("A", 4711)   ' two link fields, on an Excel UserForm

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

MasterRecordset property

Signature

Property Get MasterRecordset() As Object
Property Set MasterRecordset(RHS As Object)

Summary

Gets or sets a DAO or ADO recordset whose current record is the master.

Parameters

None

Property value: Object – The recordset, or Nothing to use the form again.

Remarks

Assign with Set. The control reads LinkMasterFields from the current record of the recordset, for example of another subform's recordset or a combo box's. In form view it checks the record on idle; SyncMaster reads it at once. A field that the recordset does not have raises wkeInvalidValue.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

SyncMaster method

Signature

Sub SyncMaster()

Summary

Reads the master values again and reloads the records when they changed.

Parameters

None

Remarks

Needed only when the master changes outside form view or must take effect at once, for example after moving MasterRecordset by code. Raises no events.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

KeyCriteria method

Signature

Function KeyCriteria(ByVal Key As Variant) As String

Summary

Returns the WHERE condition that finds the record of a key.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–A key: a value, or an array for a composite key.

Return value: String – For example [ID] = 7, or [OrderID] = 4711 AND [LineNo] = 2 for a composite key; a Null part as Is Null.

Remarks

Use it to filter a form by the selected node without building the condition by hand, also for composite keys and text or date keys.

Code example

Private Sub List1_NodeSelect(ByVal Key As Variant)
    Me.Details.Form.Filter = Me!List1.Object.KeyCriteria(Key)
    Me.Details.Form.FilterOn = True
End Sub

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

MasterFilterMode property

Signature

Property Get MasterFilterMode() As WklMasterFilterMode
Property Let MasterFilterMode(RHS As WklMasterFilterMode)

Summary

Gets or sets how a linked tree selects the records of the master record.

Parameters

None

Property value: `WklMasterFilterMode` – wmfSource (default) to read the records of each master record through a WHERE condition on the record source; wmfLocal to read the record source once and filter it in memory.

Remarks

Applies only with LinkChildFields set. wmfLocal is meant for sources that Access can only wrap, such as a pass-through query or a slow linked table: with wmfSource every master change runs the whole query again. With wmfLocal the tree reads all records once, together with the link fields, and each master change only filters them; Requery and every change the tree writes read the source again. wmfLocal loads all levels at once (LazyLoad does not apply), and searching and filtering work on the loaded records. The value is saved with the form. The designer page Link offers it as Load once, filter in memory.

Read/write.

Code example

Me!List1.Object.MasterFilterMode = wmfLocal   ' tblLines is a pass-through query

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

ColorScheme property

Signature

Property Get ColorScheme() As WklColorScheme
Property Let ColorScheme(RHS As WklColorScheme)

Summary

Gets or sets the color scheme the control draws in.

Parameters

None

Property value: `WklColorScheme` – wcoAutomatic (default), wcoLight, wcoDark or wcoHighContrast.

Remarks

wcoAutomatic follows, in this order, Windows high contrast mode, then the color set of the database design (Access: Design › Themes or Colors; the Riviera theme of the release package is one), and draws light when the database has no design. Office's own design setting (File › Account) and the Windows app mode are deliberately not followed: a database looks the same on every PC. In high contrast mode the control always uses the system colors, whatever the setting, as Office does. The scheme colors the records, headers and lines of WklTreeList and WklGantt; the native tree of WklTreeView takes background, text and search highlight from the scheme and asks Windows for the dark Explorer look of its chevrons and scroll bars with a dark scheme: background and text while BackColor and ForeColor keep their defaults (a color you set wins), headers, lines, selection, focus, group rows and marks. Every text keeps a contrast of at least 4.5:1, also with a database color set whose own colors would fall below it. The control reads the database design when it is first drawn and again with Requery, never while Access draws the form; a design chosen while the form is open shows after Requery or when the form is opened again. The value is saved with the form.

Read/write.

Code example

Me!List1.Object.ColorScheme = wcoDark

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

AllowFileDrop property

Signature

Property Get AllowFileDrop() As Boolean
Property Let AllowFileDrop(RHS As Boolean)

Summary

Gets or sets whether files and folders dragged from Windows Explorer can be dropped on the control.

Parameters

None

Property value: Boolean – True to accept files; False (default) to refuse them.

Remarks

With True the control reports a drag from Windows Explorer through FileDragOver and a drop through FileDrop; it writes nothing itself, so your code decides what a file becomes (a record, an attachment, a path in a field). The target is the node under the mouse, with the same insert mark and position as when nodes are dragged; a drop below the last node has no target. Other drags than files (text from Word, a mail from Outlook) are refused. Files are taken only in form view, not in design view. The setting is independent of AllowDragDrop, which moves nodes within the control. The value is saved with the form; a form saved before version 1.57 takes the default.

Read/write.

Code example

None

Inheritance

Declared by WklTreeView; also available on `WklTreeList`, `WklGantt`.

NodeSelect event

Signature

Event NodeSelect(ByVal Key As Variant)

Summary

Occurs when the user selects a node.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the selected node.

Remarks

In a form module: Private Sub <ControlName>_NodeSelect(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

NodeExpand event

Signature

Event NodeExpand(ByVal Key As Variant)

Summary

Occurs after a node is expanded.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.

Remarks

In a form module: Private Sub <ControlName>_NodeExpand(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

NodeCollapse event

Signature

Event NodeCollapse(ByVal Key As Variant)

Summary

Occurs after a node is collapsed.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.

Remarks

In a form module: Private Sub <ControlName>_NodeCollapse(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

NodeCheck event

Signature

Event NodeCheck(ByVal Key As Variant, ByVal Checked As Boolean)

Summary

Occurs after the user toggles a check box.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.
CheckedBooleanNo–The new state.

Remarks

In a form module: Private Sub <ControlName>_NodeCheck(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

NodeDblClick event

Signature

Event NodeDblClick(ByVal Key As Variant)

Summary

Occurs when the user double-clicks a node.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.

Remarks

In a form module: Private Sub <ControlName>_NodeDblClick(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

BeforeNodeSelect event

Signature

Event BeforeNodeSelect(ByVal Key As Variant, ByRef Cancel As Integer)

Summary

Occurs before a node is selected.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node about to be selected.
CancelInteger (by reference)No–Set to True to keep the current selection.

Remarks

In a form module: Private Sub <ControlName>_BeforeNodeSelect(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

BeforeExpand event

Signature

Event BeforeExpand(ByVal Key As Variant, ByRef Cancel As Integer)

Summary

Occurs before a node is expanded.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.
CancelInteger (by reference)No–Set to True to keep it collapsed.

Remarks

In a form module: Private Sub <ControlName>_BeforeExpand(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

BeforeCollapse event

Signature

Event BeforeCollapse(ByVal Key As Variant, ByRef Cancel As Integer)

Summary

Occurs before a node is collapsed.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.
CancelInteger (by reference)No–Set to True to keep it expanded.

Remarks

In a form module: Private Sub <ControlName>_BeforeCollapse(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

BeforeNodeCheck event

Signature

Event BeforeNodeCheck(ByVal Key As Variant, ByVal Checked As Boolean, ByRef Cancel As Integer)

Summary

Occurs before a check box is toggled.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.
CheckedBooleanNo–The new state.
CancelInteger (by reference)No–Set to True to keep the current state.

Remarks

In a form module: Private Sub <ControlName>_BeforeNodeCheck(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

NodeClick event

Signature

Event NodeClick(ByVal Key As Variant)

Summary

Occurs when the user clicks a node with the left mouse button.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.

Remarks

In a form module: Private Sub <ControlName>_NodeClick(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

NodeRightClick event

Signature

Event NodeRightClick(ByVal Key As Variant, ByVal X As Single, ByVal Y As Single, ByRef Cancel As Integer)

Summary

Occurs when the user right-clicks a node.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.
XSingleNo–The horizontal position in twips, relative to the control.
YSingleNo–The vertical position in twips, relative to the control.
CancelInteger (by reference)No–Set to True to suppress the built-in context menu, for example to show a menu of your own.

Remarks

In a form module: Private Sub <ControlName>_NodeRightClick(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

BeforeLabelEdit event

Signature

Event BeforeLabelEdit(ByVal Key As Variant, ByRef Cancel As Integer)

Summary

Occurs before the user starts renaming a node.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.
CancelInteger (by reference)No–Set to True to prevent renaming.

Remarks

In a form module: Private Sub <ControlName>_BeforeLabelEdit(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

AfterLabelEdit event

Signature

Event AfterLabelEdit(ByVal Key As Variant, ByRef NewText As String, ByRef Cancel As Integer)

Summary

Occurs after the user renamed a node, before the new text is saved.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.
NewTextString (by reference)No–The new text; the procedure can change it.
CancelInteger (by reference)No–Set to True to discard the rename.

Remarks

In a form module: Private Sub <ControlName>_AfterLabelEdit(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

NodeDragStart event

Signature

Event NodeDragStart(ByVal Key As Variant, ByRef Cancel As Integer)

Summary

Occurs when the user starts dragging a node.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.
CancelInteger (by reference)No–Set to True to prevent dragging.

Remarks

In a form module: Private Sub <ControlName>_NodeDragStart(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

NodeDragOver event

Signature

Event NodeDragOver(ByVal SourceKey As Variant, ByVal TargetKey As Variant, ByVal Position As WklDropPosition, ByVal Effect As WklDropEffect, ByRef Cancel As Integer)

Summary

Occurs when a dragged node moves over a new target.

Parameters

NameTypeOptionalDefaultDescription
SourceKeyVariantNo–The key of the dragged node.
TargetKeyVariantNo–The key of the node under the mouse.
Position`WklDropPosition`No–Where the node would be dropped relative to the target.
Effect`WklDropEffect`No–Whether the drop would move or copy.
CancelInteger (by reference)No–Set to True to forbid this target.

Remarks

In a form module: Private Sub <ControlName>_NodeDragOver(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

NodeDrop event

Signature

Event NodeDrop(ByVal SourceKey As Variant, ByVal TargetKey As Variant, ByVal Position As WklDropPosition, ByVal Effect As WklDropEffect, ByRef Cancel As Integer)

Summary

Occurs when a node is moved or copied, before the change is saved.

Parameters

NameTypeOptionalDefaultDescription
SourceKeyVariantNo–The key of the moved or copied node.
TargetKeyVariantNo–The key of the target node, or Null for the end of the roots.
Position`WklDropPosition`No–Where the node goes relative to the target.
Effect`WklDropEffect`No–Whether the node is moved or copied.
CancelInteger (by reference)No–Set to True to discard the operation.

Remarks

Raised for dragging, paste and the move up and down commands; with a multiple selection once per node.

In a form module: Private Sub <ControlName>_NodeDrop(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

AfterNodeDrop event

Signature

Event AfterNodeDrop(ByVal SourceKey As Variant, ByVal TargetKey As Variant, ByVal Position As WklDropPosition, ByVal Effect As WklDropEffect, ByVal NewKey As Variant)

Summary

Occurs after a node was moved or copied and saved.

Parameters

NameTypeOptionalDefaultDescription
SourceKeyVariantNo–The key of the moved or copied node.
TargetKeyVariantNo–The key of the target node, or Null for the end of the roots.
Position`WklDropPosition`No–Where the node went relative to the target.
Effect`WklDropEffect`No–Whether the node was moved or copied.
NewKeyVariantNo–The key of the copy; when moving, the same as SourceKey.

Remarks

In a form module: Private Sub <ControlName>_AfterNodeDrop(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

CompareNodes event

Signature

Event CompareNodes(ByVal Key1 As Variant, ByVal Key2 As Variant, ByRef Result As Long)

Summary

Occurs when two sibling nodes are compared with SortOrder = wsoCustom.

Parameters

NameTypeOptionalDefaultDescription
Key1VariantNo–The key of the first node.
Key2VariantNo–The key of the second node.
ResultLong (by reference)No–Set to a negative number when the first node comes first, 0 when both are equal, and a positive number otherwise.

Remarks

In a form module: Private Sub <ControlName>_CompareNodes(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

AfterRequery event

Signature

Event AfterRequery()

Summary

Occurs after the nodes were loaded again.

Parameters

None

Remarks

In a form module: Private Sub <ControlName>_AfterRequery(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

DataError event

Signature

Event DataError(ByVal DataErr As Long, ByVal Description As String, ByRef Response As Integer)

Summary

Occurs when loading or saving fails.

Parameters

NameTypeOptionalDefaultDescription
DataErrLongNo–The error number (one of the `WklErrorCode` values).
DescriptionStringNo–The error text.
ResponseInteger (by reference)No–Set to 0 (acDataErrContinue) to suppress the error message.

Remarks

Also raised when a list reads records while it draws, scrolls or follows the keyboard - WklGrid in server mode reads page by page: once per failure, after the current message; the window then shows the text instead of records and reads nothing more until Requery. Code that needs the records receives the error as a run-time error.

In a form module: Private Sub <ControlName>_DataError(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

KeyDown event

Signature

Event KeyDown(ByRef KeyCode As Integer, ByVal Shift As Integer)

Summary

Occurs when a key is pressed while the control has the focus.

Parameters

NameTypeOptionalDefaultDescription
KeyCodeInteger (by reference)No–The key code; set to 0 to discard the key.
ShiftIntegerNo–The state of Shift (1), Ctrl (2) and Alt (4), added.

Remarks

In a form module: Private Sub <ControlName>_KeyDown(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

KeyPress event

Signature

Event KeyPress(ByRef KeyAscii As Integer)

Summary

Occurs when a character is typed.

Parameters

NameTypeOptionalDefaultDescription
KeyAsciiInteger (by reference)No–The character code; set to 0 to discard the character.

Remarks

In a form module: Private Sub <ControlName>_KeyPress(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

KeyUp event

Signature

Event KeyUp(ByRef KeyCode As Integer, ByVal Shift As Integer)

Summary

Occurs when a key is released.

Parameters

NameTypeOptionalDefaultDescription
KeyCodeInteger (by reference)No–The key code.
ShiftIntegerNo–The state of Shift (1), Ctrl (2) and Alt (4), added.

Remarks

In a form module: Private Sub <ControlName>_KeyUp(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

MouseDown event

Signature

Event MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

Summary

Occurs when a mouse button is pressed over the control.

Parameters

NameTypeOptionalDefaultDescription
ButtonIntegerNo–The button: left (1), right (2) or middle (4).
ShiftIntegerNo–The state of Shift (1), Ctrl (2) and Alt (4), added.
XSingleNo–The horizontal position in twips.
YSingleNo–The vertical position in twips.

Remarks

In a form module: Private Sub <ControlName>_MouseDown(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

MouseUp event

Signature

Event MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

Summary

Occurs when a mouse button is released over the control.

Parameters

NameTypeOptionalDefaultDescription
ButtonIntegerNo–The button: left (1), right (2) or middle (4).
ShiftIntegerNo–The state of Shift (1), Ctrl (2) and Alt (4), added.
XSingleNo–The horizontal position in twips.
YSingleNo–The vertical position in twips.

Remarks

In a form module: Private Sub <ControlName>_MouseUp(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

MouseMove event

Signature

Event MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

Summary

Occurs when the mouse moves over the control.

Parameters

NameTypeOptionalDefaultDescription
ButtonIntegerNo–The buttons held down: left (1), right (2) and middle (4), added.
ShiftIntegerNo–The state of Shift (1), Ctrl (2) and Alt (4), added.
XSingleNo–The horizontal position in twips.
YSingleNo–The vertical position in twips.

Remarks

In a form module: Private Sub <ControlName>_MouseMove(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

MouseWheel event

Signature

Event MouseWheel(ByVal Page As Boolean, ByVal Count As Long)

Summary

Occurs when the mouse wheel turns over the control.

Parameters

NameTypeOptionalDefaultDescription
PageBooleanNo–True when the wheel scrolls by pages.
CountLongNo–The number of rows scrolled; negative when scrolling up.

Remarks

In a form module: Private Sub <ControlName>_MouseWheel(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

SelectionChange event

Signature

Event SelectionChange()

Summary

Occurs when the user changes the multiple selection (SelectedKeys).

Parameters

None

Remarks

In a form module: Private Sub <ControlName>_SelectionChange(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

BeforeNodeCopy event

Signature

Event BeforeNodeCopy(ByVal SourceKey As Variant, ByRef NewKey As Variant, ByRef Cancel As Integer)

Summary

Occurs before a node is copied.

Parameters

NameTypeOptionalDefaultDescription
SourceKeyVariantNo–The key of the node being copied.
NewKeyVariant (by reference)No–The proposed key of the copy (Null for an AutoNumber); the procedure can change it.
CancelInteger (by reference)No–Set to True to skip the copy.

Remarks

In a form module: Private Sub <ControlName>_BeforeNodeCopy(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

BeforeNodeAdd event

Signature

Event BeforeNodeAdd(ByVal ParentKey As Variant, ByRef NewKey As Variant, ByRef Text As String, ByRef Cancel As Integer)

Summary

Occurs before the user adds a node.

Parameters

NameTypeOptionalDefaultDescription
ParentKeyVariantNo–The key of the parent, or Null for a new root.
NewKeyVariant (by reference)No–The proposed key (Null for an AutoNumber); the procedure can change it.
TextString (by reference)No–The proposed text; the procedure can change it.
CancelInteger (by reference)No–Set to True to prevent the addition.

Remarks

In a form module: Private Sub <ControlName>_BeforeNodeAdd(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

AfterNodeAdd event

Signature

Event AfterNodeAdd(ByVal Key As Variant)

Summary

Occurs after a node was added and saved.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the new node.

Remarks

In a form module: Private Sub <ControlName>_AfterNodeAdd(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

BeforeDelete event

Signature

Event BeforeDelete(ByVal Key As Variant, ByVal Count As Long, ByRef Cancel As Integer, ByRef Confirm As Boolean)

Summary

Occurs before the user deletes a node.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.
CountLongNo–The number of nodes that will be deleted, the node's subtree included.
CancelInteger (by reference)No–Set to True to prevent the deletion.
ConfirmBoolean (by reference)No–Set to False to suppress the confirmation message.

Remarks

In a form module: Private Sub <ControlName>_BeforeDelete(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

AfterDelete event

Signature

Event AfterDelete(ByVal Key As Variant)

Summary

Occurs after a node was deleted with its subtree.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the deleted node.

Remarks

In a form module: Private Sub <ControlName>_AfterDelete(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

BeforeUpdate event

Signature

Event BeforeUpdate(ByVal Key As Variant, ByVal Action As WklUpdateAction, ByRef Cancel As Integer)

Summary

Occurs before each write into the record source caused by an action of the user.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the affected record; Null for a new record with an AutoNumber key.
Action`WklUpdateAction`No–The kind of change.
CancelInteger (by reference)No–Set to True to cancel the whole operation; everything already written is rolled back.

Remarks

One user action can write several records (for example a copied subtree); all writes of an action share one transaction.

In a form module: Private Sub <ControlName>_BeforeUpdate(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

AfterUpdate event

Signature

Event AfterUpdate(ByVal Key As Variant, ByVal Action As WklUpdateAction)

Summary

Occurs after each write into the record source caused by an action of the user.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the written record.
Action`WklUpdateAction`No–The kind of change.

Remarks

In a form module: Private Sub <ControlName>_AfterUpdate(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

NodeFormat event

Signature

Event NodeFormat(ByVal Key As Variant, ByRef ForeColor As Long, ByRef BackColor As Long, ByRef Bold As Boolean, ByRef Italic As Boolean)

Summary

Occurs before a node is shown in form view, to format it.

Parameters

NameTypeOptionalDefaultDescription
KeyVariantNo–The key of the node.
ForeColorLong (by reference)No–The text color; -1 for the default. The procedure can change it.
BackColorLong (by reference)No–The background color; -1 for the default. The procedure can change it.
BoldBoolean (by reference)No–True for bold text; the procedure can change it.
ItalicBoolean (by reference)No–True for italic text; the procedure can change it.

Remarks

Raised only with FormatEvents = True, for every visible node on every redraw. Keep the procedure short and avoid queries in it.

In a form module: Private Sub <ControlName>_NodeFormat(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

Signature

Event MenuItemClick(ByVal Tag As String, ByVal Key As Variant)

Summary

Occurs when the user clicks a custom menu item.

Parameters

NameTypeOptionalDefaultDescription
TagStringNo–The tag given to AddMenuItem.
KeyVariantNo–The key of the node the menu was opened on.

Remarks

In a form module: Private Sub <ControlName>_MenuItemClick(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

BeforeMasterChange event

Signature

Event BeforeMasterChange(ByVal Values As Variant, ByRef Cancel As Integer)

Summary

Occurs before the tree changes to the records of another master record.

Parameters

NameTypeOptionalDefaultDescription
ValuesVariantNo–The new master values (a value, an array, or Null for no master record).
CancelInteger (by reference)No–Set to True to keep the current records.

Remarks

Raised for changes of the form's record and of MasterRecordset, not when MasterValues is set by code.

In a form module: Private Sub <ControlName>_BeforeMasterChange(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

AfterMasterChange event

Signature

Event AfterMasterChange(ByVal Values As Variant)

Summary

Occurs after the tree was loaded with the records of another master record.

Parameters

NameTypeOptionalDefaultDescription
ValuesVariantNo–The new master values.

Remarks

In a form module: Private Sub <ControlName>_AfterMasterChange(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

FileDragOver event

Signature

Event FileDragOver(ByVal Files As Variant, ByVal TargetKey As Variant, ByVal Position As WklDropPosition, ByRef Cancel As Integer)

Summary

Occurs when files from Windows Explorer are dragged over a new target (AllowFileDrop).

Parameters

NameTypeOptionalDefaultDescription
FilesVariantNo–A 0-based array of the full paths of the dragged files and folders, in the order Explorer lists them.
TargetKeyVariantNo–The key of the node or record under the mouse, or Null below the last one (and on a group row or the row for a new record of WklGrid).
Position`WklDropPosition`No–Where the files would be dropped relative to the target.
CancelInteger (by reference)No–Set to True to forbid this target; the mouse pointer then shows that the files cannot be dropped there.

Remarks

The event occurs once for each new target or position, not on every movement of the mouse. Windows Explorer waits for the handler while the user drags, so keep it short: decide from the paths and the target, do not open files or show messages here.

In a form module: Private Sub <ControlName>_FileDragOver(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

FileDrop event

Signature

Event FileDrop(ByVal Files As Variant, ByVal TargetKey As Variant, ByVal Position As WklDropPosition)

Summary

Occurs when files from Windows Explorer were dropped (AllowFileDrop).

Parameters

NameTypeOptionalDefaultDescription
FilesVariantNo–A 0-based array of the full paths of the dropped files and folders.
TargetKeyVariantNo–The key of the node or record the files were dropped on, or Null below the last one.
Position`WklDropPosition`No–Where the files were dropped relative to the target.

Remarks

The event occurs after the drop has ended, so Windows Explorer is free again while the handler runs; the handler may show messages, copy files or write records. The control changes nothing: add records, store paths or read the files in the handler, then call Requery if the control should show new records. A target for which FileDragOver set Cancel never receives a drop. Folders appear as paths like files; use GetAttr to tell them apart.

In a form module: Private Sub <ControlName>_FileDrop(...). Parameters passed by reference can be changed by the procedure.

Code example

None

Inheritance

Declared by WklTreeView.

en/wiki/msaccess/comctl/api-reference/wkltreeview.txt · Last modified: by Wolfgang van der Stille