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?
Brian, I decided to go ahead and see the effect of setting the ColSet into the Node override. I did this in my sample that I previously uploaded by removing the Nodes override and applying the override to the node with the columns:
oNode = ndRx.Nodes.Add()
' Assign the 'rnox' column set to the orders node node's collection
oNode.Override.ColumnSet = utPlanCare.ColumnSettings.ColumnSets(
"rnox")
I still get Nothing for the Node when I walk the element up to the header. So is this now a bug?
Brian, Thanks for the specifics as to exactly why I could not get the Node. Now knowing that I want to get the Node of the Nodes collection that has that column header (i.e. the ColumnSet) is there any way to get that? I do not see any property to get the rows of the column so I can look at the 1st data row where I have a data object in the Node of that row that shows me the parent. And I do not see any property when assigning a ColumnSet to a Nodes override to set a data object into the column set's Tag property. And I gather that when I set a ColumnSet, that it is the same ColumnSet object that is attached to other Nodes where I use the same set of columns. So is there no way built in - short of attempting to find the node element in question by fudging the point location? I am glad that you can make it clear as to why my code did not work; but you may have more insight as to what would work. I appreciate any effort that may help me solve this problem.
You are assigning the column set to the Override of the Nodes collection, not to the Override for an individual node, therefore the header is not uniquely associated with one particular node, which is why the Node property for the UltraTreeNodeColumnHeaderUIElement returns null. There is nothing wrong with your code, but the UltraTreeNodeColumnHeaderUIElement.Node property only returns a non-null value when the header is distinctly associated with one node, and this only happens when the column set is assigned to the UltraTreeNode.Override.