I have a two Ultratree controls...the first tree control is on a form that is restricted in height and width. So I have a popup component that floats over the form and the height and width is much bigger to all the user to see more detail of the data. The goal is that when I select a node from the popup form is that it is transfered back to the original form. I have an event that passes back the selectednodes collection. I was trying to loop through the orignal tree and have not been able to find anything on how I would programically select the original tree with the same selection from the popup tree.
Thanks for any help on this
Public Sub SetSelectedNode(ByVal selectedNodes As SelectedNodesCollection)
For Each node As UltraWinTree.UltraTreeNode In selectedNodes
If node.Selected Then
For Each treenode As UltraWinTree.UltraTreeNode In ResultsTree.Nodes
If node.FullPath = treenode.FullPath Then 'NOTE problem with this is some node paths with the same name.
'ResultsTree.ActiveNode.Selected = True 'NOTE Doesn't work
'ResultsTree.Nodes.Item(treenode.Key).Selected = True 'NOTE not sure this work plus I don't have the key set and dont know how.
End If
Next
End Sub
rrober07 said:'ResultsTree.ActiveNode.Selected = True 'NOTE Doesn't work
What exactly is not working? Is the Selected property not return true after you set it?
My guess is that your code is working fine, but you just don't see the selected nodes in the tree because the tree does not have focus. Try setting HideSelection on the tree to false or activating the tree control so that you can see the selection.
Thank you for your response...
It did finally work...I reworked my solution below
For Each node As UltraWinTree.UltraTreeNode In selectedNodes If node.Selected Then ResultsTree.Nodes.Item(node.Index).Selected = True Next
Richard
It looks like I figure out my problem: Here is the code I am using:
I am having to call the click event of the ResultsTree in code...
Private Sub FindChild(ByVal parentNode As Infragistics.Win.UltraWinTree.UltraTreeNode, ByVal childNode As Infragistics.Win.UltraWinTree.UltraTreeNode, ByVal selectedNodes As SelectedNodesCollection, ByVal e As System.EventArgs) If parentNode.Parent Is Nothing Then For Each node As UltraWinTree.UltraTreeNode In ResultsTree.Nodes(parentNode.Index).Nodes If node.Index = childNode.Index Then ResultsTree.Nodes(parentNode.Index).Expanded = True node.Selected = True _isExpandingCollapse = False If _activateOnSelection Then ResultsTree_Click(selectedNodes, e) Exit For End If Next Else FindChild(parentNode.ParentNodesCollection.ParentNode, parentNode, selectedNodes, e) End If End Sub
Hi Richard,
What, exactly, is the difference?
Yes that works...one last problem I am having is that even though I am causing the ResultsTree to be selected...It isn't causing the tree to act like it was selected by the user as if they phyically clicked on the ResultsTree. Is there a method that would cause that action to occur?
Thanks for you help!
UltraTreeNode exposes an Expanded property and an ExpandAll method. The former expands only that node, where the latter expands it and all descendants.
One more question...How do you make the node expand?...I will keep working on this too...
Thanks,