In a treeview, I need to be able to determine what part of a node has been clicked by the mouse. Mostly I need to differentiate between a click on a left image and a click on the node's text.
You could use the UIElement.ElementFromPoint method to hit test for an ImageUIElement:
private void ultraTree1_MouseDown(object sender, MouseEventArgs e){ UltraTree tree = sender as UltraTree; UIElement controlElement = tree.UIElement; UIElement elementAtPoint = controlElement != null ? controlElement.ElementFromPoint( e.Location ) : null; bool imageAtPoint = false; while ( elementAtPoint != null ) { if ( elementAtPoint is ImageUIElement ) { imageAtPoint = true; break; }
elementAtPoint = elementAtPoint.Parent; }
if ( imageAtPoint ) { }}
This worked perfectly. I had never noticed this in any of the controls before. A whole new realm of possibility.
thanks
If you are interested in UIElements, I recommend you check out the Infragistics UIElementViewer Utility