VB skills-Tree View TreeView usage skills
1. Add nodes and subnodes for tree browser controls
When you use the ADD method to ADD a new node to the node set in the tree browser, you can declare that it is associated with an existing node. The ADD method is usually used. Its syntax is as follows:
Nodes. Add (relative, [relationship] [, key] [, text] [, image] [, selectedimage])
The meanings of parameters are as follows:
The relationship parameter is another node connected to the new node through the link node parameter;
The relationship parameter may be:
Tvwlast -- 1; this node is placed behind all other nodes of the same level named in relative.
TvwNext -- 2; this node is placed behind the named node in relative.
TvwPrevius -- 3; this node is placed in front of the node named in relative
TvwChild -- 4; this node becomes the child node of the node named in relative
The following is an example:
Dim node1, node2, node3, node4 as Node
Set Node1 = TreeView1.Nodes. Add
TreeView1.Nodes (1). text = "node1"
TreeView1.Nodes (1). key = "node1"
Set node2 = treeview. nodes. add ("node1", tvwChild, "node2 ")
TreeView1.Nodes (2). text = "node2"
TreeView1.Nodes (2). key = "node2"
Insert nodes in sequence.
2. Insert images for nodes
Treeview1.node (3). image = "leaf"
Note that we generally specify the image from imagelist
3. How can I know which node of the tree browser has been clicked when processing node clicks? You can use the NodeClick event:
Public sub treeview1_nodeclick (byval node as comctllib. node)
Text1.text = "you click" & node. text
End sub