I have a tree that looks partially like the following:
I am using a context menu on a right click. I can detect clicking on a column header from the MouseUp event by walking up the ElementFromPoint at the mouse location to get the UltraTreeNodeHeaderUIElement. But the Node property is always null (Nothing). That Node property is documented as "Returns the UltraTreeNode instance associated with this UltraTreeNodeColumnHeaderUIElement instance, or null if it is not associated with a specific node". I assume that each of my column headers is associated with the node to which the column set is 'attached' since I have a column header on very node that has a column set. I need to find the parenting node (in the first case, the parenting node is 'Medication Care'). Short of trying to adjust the mouse location arbitrarily to try to find the node immediately above the column header, is there a particular way to find it?
I believe the Node property only returns a non-null value when using the FreeForm ViewStyle and the node's Override.ColumnSet property is set to a ColumnSet.
I have attached a small VB.Net project that populates the tree and has a handler for the MouseUp event I am using. The header's Node property is always Nothing; I have the ViewStyle set to FreeForm and there is a column set attached to the parent node's nodes property. So what am I doing wrong?
I have verified that the ViewStyle is FreeForm and obviously there is a column set override on the node as is observer in the graphic from my first post. Here is my code that walks the element:
' Get the element at that pointDim element As UIElement = mainElement.ElementFromPoint(e.Location)While element IsNot Nothing Dim oHeader As UltraTreeNodeColumnHeaderUIElement = TryCast(element, UltraTreeNodeColumnHeaderUIElement) If (oHeader IsNot Nothing) Then Dim Index As Integer = oHeader.Column.Index + 2 ' Menu items are +2 For i As Integer = 2 To myMenuRNOx.MenuItems.Count - 1 myMenuRNOx.MenuItems(i).Enabled = i = Index Next oNode = oHeader.Node If (oNode IsNot Nothing) Then myPOCEventData = oHeader.Node.Tag End If myMenuRNOx.Show(utPlanCare, e.Location) Exit Sub End If element = element.ParentEnd While
This is the line of code that assigned the ColSet:
' Assign the 'rnox' column set to the orders node node's collectionoNode.Nodes.Override.ColumnSet = utPlanCare.ColumnSettings.ColumnSets("rnox")
Any other ideas?