DIAdem-Hilfe

Method: ScrollNodeInView for Tree

  • Aktualisiert2024-09-12
  • 2 Minute(n) Lesezeit

Method: ScrollNodeInView for Tree

Displays in dialog boxes a node in the tree. If necessary, DIAdem opens the associated branches and moves the node into the visible area.

Object.ScrollNodeInView(Node)
ObjectTree
Object with this method
NodeTreeNode
Specifies which node to search for.

The following example first creates a tree and fills a selection list with the key properties of the tree nodes. When you select a key in the ListBox1 selection list and then click the Button1 button, the example opens the associated branches and moves the nodes into the visible area.

Sub ListBox1_EventInitialize(ByRef This)
  Call CreateDefaultTree(Tree1)
  Call FillListBox(Tree1)
End Sub

Sub FillListBox(oNode)
  Dim oMyNode
  For Each oMyNode in oNode.Nodes
    If oMyNode.Key <>"" Then
      Call ListBox1.Items.Add(oMyNode.Key,0)
    End If
    Call FillListBox(oMyNode)
  Next
End Sub

Sub Button1_EventClick(ByRef This)
  Dim oMyNode
  Set oMyNode = Tree1.GetNode(ListBox1.Text)
  Tree1.ScrollNodeInView(oMyNode)
End Sub

Sub CreateDefaultTree(ByRef This)
  Dim oFindRoot, oRoot, oMainNode
  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