Hi,
I have a WinTree that is populated at runtime based on the users selection. Once populated the user of course selects a node, and then the program continues from there.
However, the issue I have is that I have used the example code from the Infragistics Help file to determine which node was selected and the event fires even when the user simply clicks on the Plus (+) to expand a node.
private void ultraTree1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e){UltraTree tree;tree = sender as UltraTree;UltraTreeNode aNode;aNode = tree.GetNodeFromPoint(e.X, e.Y);if (aNode != null)this.ultraTextEditor1.Text = aNode.Text; }
object
as
if
null
this
How can I determine the selected node with the event only firing when the user clicks on the node itself instead of on the expand/collapse node symbol.
Cheers
Jason
Jason,
You could add a filter to your code based on what UIElement recieved the mouse event.
private void ultraTree1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e){UltraTree tree;tree = sender as UltraTree; Infragistics.Win.UIElement ui = tree.UIElement.ElementFromPoint( new System.Drawing.Point(e.X, e.Y)); if (ui is Infragistics.Win.UltraWinTree.NodeSelectableAreaUIElement || null != ui.GetAncestor(typeof(Infragistics.Win.UltraWinTree.NodeSelectableAreaUIElement))) { UltraTreeNode aNode; aNode = tree.GetNodeFromPoint(e.X, e.Y); if (aNode != null) this.ultraTextEditor1.Text = aNode.Text; }}
private void ultraTree1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e){UltraTree tree;tree = sender as UltraTree;
Infragistics.Win.UIElement ui = tree.UIElement.ElementFromPoint( new System.Drawing.Point(e.X, e.Y)); if (ui is Infragistics.Win.UltraWinTree.NodeSelectableAreaUIElement || null != ui.GetAncestor(typeof(Infragistics.Win.UltraWinTree.NodeSelectableAreaUIElement))) {
UltraTreeNode aNode; aNode = tree.GetNodeFromPoint(e.X, e.Y); if (aNode != null) this.ultraTextEditor1.Text = aNode.Text;
}}
That should allow you to concentrate on the text area of the node rather than the expansion indicator.
Would someone please convert the filter part of the code to VB 2005. I have been trying for some time to apply this code into my VB project but have been having troubles.
I am trying to accomplish the same things as the orginal post author.
Infragistics.Win.UIElement ui = tree.UIElement.ElementFromPoint( new System.Drawing.Point(e.X, e.Y)); if (ui is Infragistics.Win.UltraWinTree.NodeSelectableAreaUIElement || null != ui.GetAncestor(typeof(Infragistics.Win.UltraWinTree.NodeSelectableAreaUIElement)))
In VB, the code would look something like this:
Private Sub UltraTree1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles UltraTree1.MouseUp Dim tree As UltraTree tree = CType(sender, UltraTree) Dim ui As Infragistics.Win.UIElement = tree.UIElement.ElementFromPoint(New System.Drawing.Point(e.X, e.Y)) If Not TypeOf ui Is Infragistics.Win.UltraWinTree.NodeSelectableAreaUIElement Then ui = ui.GetAncestor(GetType(Infragistics.Win.UltraWinTree.NodeSelectableAreaUIElement)) End If If (Not ui Is Nothing) Then Dim aNode As UltraTreeNode aNode = tree.GetNodeFromPoint(e.X, e.Y) If (Not aNode Is Nothing) Then Me.ultraTextEditor1.Text = aNode.Text End If End If End Sub