TreeNode question - EnsureVisible


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I figured out my problem.



Both of these do work:



myTree.SelectedNode=someNode

someNode.Ensurevisible()



They both expand the tree and scroll tree so the node is visible.



My problem was that the node I was working with wasn't valid...long story Crazy



Thanks for you help in any case!
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I think that your problem is that the parent node is not expanded.  I wrote this little test to create 100 items, each with a child node, and then select the child node inside of the last parent node and make sure it is selected and visible.  This code is dirty, but it should give you a general idea:

''' <summary>
''' Populates the tree view with the slides
''' </summary>
''' <remarks></remarks>
Private Sub LoadSlidesInTree()
'-- Establish Locals
Dim loNode As TreeNode
Dim lnCnt As Integer

For lnCnt = 0 To 100
    loNode =
New TreeNode("Item " & lnCnt.ToString())
    loNode.Nodes.Add(
"Child Node")

    Me.MyTreeView.Nodes.Add(loNode)
Next

'-- Expand and show the last node
loNode.ExpandAll()
Me.MyTreeView.SelectedNode = loNode.Nodes(0)
loNode.Nodes(0).EnsureVisible()

End Sub

You should see some results like this:


Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
For some reason I cannot get a TreeNode to become visible. The code looks like this:



' Find a node based on key

dim aNode as TreeNode = me.tvwAny.Find(key,false)(0)



' Make the node visible, but it doesn't when I do it

aNode.EnsureVisible()



' This theortically will also make it visible

me.tvwAny.SelectedNode = aNode



So, is there some property on the treeview that I must set for this to work? Am I doing something wrong?



I appreciate any help offered!

Greg

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search