DIAdemヘルプ

Method: GetNode for Tree

  • 更新日2024-09-12
  • 6分で読める

Method: GetNode for Tree

Uses a unique key to specify a node. The node can be anywhere in the tree of a user dialog box. If the node does not exist, the method returns the value Nothing.

Set oTreeNode = Object.GetNode(Key)
ObjectTree
Object with this method
KeyString
Specifies a unique key for the node.
oTreeNodeTreeNode
Returned object

The following example creates a tree. When you click the Button1 button, the example opens the entry hammer and if necessary, the related branch in the tree:

Sub Tree1_EventInitialize(ByRef This)
  Call CreateDefaultTree(This)
End Sub

Sub Button1_EventClick(ByRef This)
  Dim oMyNode
  Set oMyNode = Tree1.GetNode("hammer")
  Tree1.ScrollNodeInView(oMyNode)
End Sub

Sub CreateDefaultTree(ByRef This)
  Dim oFindRoot, oRoot, oMainNode
  Set oFindRoot = This.Nodes.Add("Double click to find hammer")
  Set oRoot = This.Nodes.Add("Tools")
  oRoot.Key = "tools"
  oRoot.Expanded = true
  Set oMainNode = oRoot.Nodes.Add("Electric Tools")
  oMainNode.Key = "electric"
  oMainNode.Nodes.Add("Drill").Key = "drill"
  oMainNode.Nodes.Add("Saw").Key = "saw"
  Set oMainNode = oRoot.Nodes.Add("Hand Tools")
  oMainNode.Key = "handtool"
  oMainNode.Nodes.Add("Hammer").Key = "hammer"
  oMainNode.Nodes.Add("Screwdriver").Key = "screwdriver"
End Sub