I am looking for a way to sort only certain Child nodes.
Example Tree: The top level categories should be manually sorted while the items should be in alpha order.
I originally set the .Override.Sort property to the category nodes to Ascending but that didn't appear to have any effect. I have also tried to use columnsets but even with manually clicking on the column headers sorting never changed. The direction arrow flipped but the data never moved. I am using 2007 vol 3.
I think Frans is thinking of UltraWinGrid. UltraWinTree doesn't have "bands".
The solution to your problem is to use a different Override. The Override on the tree control affects all the nodes in the tree. But there are also Overrides on the Nodes collection. So what you would do is set the Sort property on the nodes collection of each parent node instead of on the tree's override.
Mike, thanks for the clarification. Though that describes what I am trying to do. The Treeview.Override.Sort has been set to Default. ViewStyle = Standard. Here is my code below. Note that I am setting the Node.Override.Sort = Ascending. Anything that you can see
' Code to add the Categories Nodes
Dim oStartNode As UltraTreeNodeoStartNode = utvItems.GetNodeByKey("MasterOrder")
With oStartNode.Nodes
Dim oNewNode As New UltraTreeNode(String.Format("MO{0}", JobID), JobName)oNewNode.Override.ActiveNodeAppearance.FontData.Bold = DefaultableBoolean.TrueoNewNode.Override.NodeAppearance.Image = My.Resources.FolderClosed_SmalloNewNode.Override.ExpandedNodeAppearance.Image = My.Resources.FolderOpen_SmalloNewNode.Override.Sort = SortType.Ascending.Add(oNewNode)
End With
' Code to add each Item to the Categories
Dim oCatNode As UltraTreeNodeoCatNode = utvItems.GetNodeByKey(String.Format("MO{0}", JobID))
With oCatNode.Nodes
Dim oNewNode As New UltraTreeNode(String.Format("I{0}", dr("iItemID").ToString), String.Format("{0} - {1}", dr("sEPICCode").ToString, dr("sItemDesc").ToString)) oNewNode.Override.NodeAppearance.Image = My.Resources.Green_48oNewNode.Override.ActiveNodeAppearance.FontData.Bold = DefaultableBoolean.True .Add(oNewNode)
Dim oNewNode As New UltraTreeNode(String.Format("I{0}", dr("iItemID").ToString), String.Format("{0} - {1}", dr("sEPICCode").ToString, dr("sItemDesc").ToString))
oNewNode.Override.NodeAppearance.Image = My.Resources.Green_48oNewNode.Override.ActiveNodeAppearance.FontData.Bold = DefaultableBoolean.True
.Add(oNewNode)
Well, you are setting Sort on the Node, not the Nodes collection. You are essentially sorting a single node, which of course has no meaning.
I think you need to change:
oNewNode.Override.Sort = SortType.Ascending
to
.Override.Sort = SortType.Ascending
Ok, I tried your solution. Unfortuantely there was no change in the behavior. Question about the solution:
Basically what I am doing is loading the treeview with the second level folders. As I load them I set the .Override.Sort = Ascending. From a second procedure I load the third level which are the nodes that I want to have sorted. From your response it would appear that I should set the Override.Sort on the FIRST level, not the SECOND. Is that correct?
Could this be a control property problem? Such as the ViewState? Also, I am calling the RefreshSort method just after I complete the load of all items. Should I not do this?
Thanks again for your attention and patience.
I'm really not sure I understand what you are trying to do. The Sort property exists on the Override. That means you can set it many different levels. There is an Override on the tree control itself - this will affect all nodes in the tree.
There is an Override on every Nodes collection that will affect all the nodes in that collection.
There is an Override on the Node itself, which will only affect a single node - this obviously has no effect on sorting, since it makes no sense to sort a single node, but there are other properties on the Override that apply.
There is also the NodeLevelOverrides collection, which allows you to apply settings to a particular level. For example, NodeLevelOverrides(0) would affect all root-level nodes. NodeLevelOverrides[1] would affect all nodes that are direct children of the root.
Eureka. It finally sunk in. Here is what I needed to do.
When I was creating the 'category' nodes I was setting the sort override like this:
oNewNode.Override.Sort = Ascending (as you mentioned this is worthless and does nothing)
it needed to be
oNewNode.Nodes.Override.Sort = Ascending.
Thank you for your help. Knew it was something simple that I was just overlooking.