Friday, September 24, 2004

Infragistics.Win tip: Determining if the mouse is over an element

For some reason best known to themselves, the developers at Infragistics didn't think to include a double click event for specific elements like rows or nodes (in the UltraWinGrid and UltraWinTree classes, respectively).

The hack I've resorted to to fix this looks like this:

/// <summary>Determines whether the mouse is over a node.</summary>
/// <returns><c>true</c> if the mouse if over a node; otherwise, <c>false</c>.</returns>
private bool IsMouseOverNode()
	bool result = false;
		Infragistics.Win.UIElement uiElem = 
		Infragistics.Win.UIElement nodeUIElem = 
			uiElem.GetAncestor(typeof (Infragistics.Win.UltraWinTree.TreeNodeUIElement));
		result = (nodeUIElem != null);
	return result;
where tree is my Tree control instance. For a Grid, replace the guts with the following:
		Infragistics.Win.UIElement uiElem =
		Infragistics.Win.UIElement rowUIElem = 
			uiElem.GetAncestor(typeof (Infragistics.Win.UltraWinGrid.RowUIElement));
		result = (rowUIElem != null);


Post a Comment

<< Home