I want to be able to set the active node to nothing in my ultratree. When I do that it automatically activates the first node in the tree. I have my tree bound to a datasource and the style set to Windows Vista. Is there anyway I can make it so that there is no active node in the tree?
BTW - The new forum layout looks great!
Unfortunately that is legacy behavior that cannot be changed as it would be too destabilizing (could be code out there that assumes ActiveNode never returns null when there are nodes). If you can briefly explain why you need it to be null we can try to help.
In my example I have a list of folders (tree nodes) where the user can select to copy files into or create a new folder. Essentially a mock file system. Selecting no node would result in copying files\creating folders at the root. However, even though no node is selected the top node is still activated and looks like it is selected (because of the Vista style).
This is really an appearance issue for me. If I can work with a draw filter that would work. I just need to be able to say, "Don't give any appearance attributes to the active node if DoNotDrawActiveNode = True."
Thanks for any help on this.
Here is the code I came up with to do the drawfilter. Please let me know if there is a better or more efficient way of doing this:
Public Class NoActiveNodeDrawingFilter
Implements Infragistics.Win.IUIElementDrawFilter
Public Function DrawElement(ByVal drawPhase As Infragistics.Win.DrawPhase, ByRef drawParams As Infragistics.Win.UIElementDrawParams) As Boolean Implements Infragistics.Win.IUIElementDrawFilter.DrawElement
Dim treeNode As UltraTreeNode = drawParams.Element.GetContext(GetType(UltraTreeNode), True)
If Not (treeNode Is Nothing) Then
If Not treeNode.Selected Then
drawParams.AppearanceData.BackColor = Color.White
drawParams.AppearanceData.BackColor2 = Color.White
drawParams.AppearanceData.BorderColor = Color.White
drawParams.AppearanceData.BorderColor2 = Color.White
Return True
End If
End Function
Public Function GetPhasesToFilter(ByRef drawParams As Infragistics.Win.UIElementDrawParams) As Infragistics.Win.DrawPhase Implements Infragistics.Win.IUIElementDrawFilter.GetPhasesToFilter
If Not treeNode Is Nothing Then
Return DrawPhase.BeforeDrawBackColor
End Class
You can set the selected appearance on a per-node basis using the UltraTreeNode.Override.SelectedNodeAppearance property for that one node.
Also note that it looks like you are actually referring to the selected node and not the ActiveNode; unlike the ActiveNode property, which cannot be null, the SelectedNodes collection can in fact be empty, so that selection is not depicted for any node. You can set the Selected property of the node in question to false.