After the Treeview control is created, you can perform operations on each node object by setting properties and calling methods. These operations include adding, deleting, alignment, and other operations. You can expand and collapse node objects programmatically to show or hide all child nodes. Collapse, expand, and nodeclick events also provide programming functions.
1. common attributes
(1) The nodes attribute returns a reference to the Node object set of the Treeview control.
[Syntax] object. Nodes
An object represents an object expression. You can use standard collection methods (such as the add and remove methods) to operate on a Node object. You can access each element in the set by pressing its index or the unique key stored in the key attribute.
(2) The style property returns or sets the image type (image, text, +/-, straight line) and the type of text that appears on each node object in the Treeview control.
[Syntax] object. Style [= number]
An object represents an object expression. Number specifies an integer of the graphic type. The value of number is 0, which is only text. 1 is image and text, and 2 is +/-and text; 3: +/-, image, and text; 4: Line and text; 5: line, image, and text; 6: line, +/-, and text; 7 (default) it is a straight line, A +/-number, an image, and a text. If the style attribute is set to include the value of a straight line, the linestyle attribute determines the appearance of the line. If the style attribute is set to not include the value of a straight line, the linestyle attribute is ignored.
(3) The sorted attribute returns or sets a value to determine whether the root node or subnode of the Node object is listed alphabetically.
[Syntax] object. Sorted [= Boolean]
An object represents an object expression. Boolean value: True -- node objects are listed alphabetically according to their text attributes. The text attribute of the Node object starts with a number is also sorted as a string. The first number is the initial position in the sorting, and the subsequent number is the sorting. False -- node objects are not sorted. Sorted attributes can be used in two ways. First, the node objects are arranged at the root (top) layer of the Treeview control. Second, the nodes of any single Node object are sorted.
Set the sorted attribute to true to only sort the current nodes set. When adding a new Node object to the Treeview control, you must set the sorted attribute to true again to arrange the added node objects.
(4) appearance property: sets whether the control is displayed in 3D.
(5) checkboxes attributes: determines whether a check box is displayed next to each item of the node, similar to the functions of the checkbox control.
(6) hottracking properties: determines whether these entries are highlighted when the mouse pointer passes through an entry, similar to the hyperlink effect of a webpage.
(7) labeledit attribute: determines whether the user can edit the items listed in the control. If this item does not want to be changed, set the attribute value to 1.
(8) linestyle attribute: Set the row style between each item listed, that is, if it is 1, there are sub-items under the current item, "+" is displayed before it. If the value is 2, "+" is not displayed"
(9) singlesel attribute: when a new entry is selected in the tree, whether to expand the entry and collapse the previous entry, that is, when it is set to true, when the selected item has a subitem, the subitem is expanded and the selected item is collected.
(10) style attribute: Set the composition of each list of the Treeview control, such as "image" + "text", so that the Treeview can be more beautiful.
2. Common Methods
(1) Add Method
Add a Node object to the nodes set of the Treeview control.
[Syntax] object. Add (relative, relationship, key, text, image, selectedimage)
[Description]
The parameter object is required and is an object expression.
The relative parameter is optional and represents the index number or key value of an existing Node object.
The relationship parameter is optional and represents the relationship between the new node and the existing node. It specifies the relative position of the Node object. The value of relationship is:
0 -- the first tvwfirst node. The node and the node named in relative are located at the same layer and before all the nodes at the same layer.
1 -- the last node of tvwlast. The node and the node named in relative are located at the same layer and behind all the same layer nodes. Any consecutively added node may be behind the last added node.
2 -- tvwnext (default): Next node, which is located after the node named in relative.
3 -- tvwprevious, the previous node, which is located before the node named in relative.
4 -- tvwchild (default), subnode. This node is the child node of the node named in relative.
The parameter key is an optional and unique string that can be used to retrieve the node using the item method.
The text parameter is a required string that appears in node.
The image parameter is optional and represents an image or an image index in the imagelist control.
The selectedimage parameter is optional and represents an image or an image index in the imagelist control. It is displayed when the node is selected.
NOTE: If no Node object is named in relative, the new node is placed at the last position on the top of the node.
(2) getvisiblecount Method
Returns the number of node objects fixed in the internal area of the Treeview control.
[Syntax] object. getvisiblecount
An object represents an object expression. The number of node objects depends on the number of rows that can be fixed in a window. The total number of rows depends on the height of the control and the size attribute of the font object. You can use the getvisiblecount attribute to ensure the minimum number of lines visible, so that you can accurately access a layer. If the minimum number of rows is invisible, you can use the height attribute to reset the Treeview size.
3. Common events
The nodeclick event occurs when a Node object is clicked.
[Syntax] private sub object_nodeclick (byval node as node)
Object represents an object expression. The parameter node is a reference to the Node object obtained by the vertex.
Note: a standard click event occurs in any part of the Treeview control other than the Node object. When you click a specific Node object, the nodeclick event occurs. The nodeclick event also returns a reference to a specific Node object. Before the next operation, the reference can be used to make the Node object available. The nodeclick event occurs before the standard click event.