There seems to be an issue with consistency when capture the current UIElement.
I can click on the same cell multiple times on Band[0] and I get two different Elements randomly.
CellUIElement Or RowColRegionIntersectionUIElement
This isn't that big of a problem because when if a RowColRegionIntersectionUIElement returned the below code should work for figuring out what cell got clicked....The problem is that the below code doesn't work .
The line cellElement.Rect.Contains(currentPoint) always returns false and it should be returning true at least once. Why would the below code be failing to return the Cell when starting at RowColRegionIntersectionUIElement and moving down?? Any help is appreciated
Thanks-Ken
if (currentPoint != null){ CellUIElement cellElement; RowColRegionIntersectionUIElement rowColRegionIntersectionUIElement; UIElement uiElement = grid.DisplayLayout.UIElement.ElementFromPoint(currentPoint); if (uiElement != null) { if (uiElement is CellUIElement) cellElement = (CellUIElement)uiElement; else cellElement = uiElement.GetAncestor(typeof(CellUIElement)) as CellUIElement; if (cellElement == null) { //check if we have a rowColRegion rowColRegionIntersectionUIElement = uiElement.GetAncestor(typeof(RowColRegionIntersectionUIElement)) as RowColRegionIntersectionUIElement; //if we still don't have a CellUIElement //or RowColRegionIntersectionUIElement...we should bail if (rowColRegionIntersectionUIElement == null) return null; foreach (UIElement childElement in rowColRegionIntersectionUIElement.ChildElements) { RowUIElement rowUIElement = childElement as RowUIElement; if (rowUIElement == null) continue; foreach (UIElement rowChildElement in rowUIElement.ChildElements) { RowCellAreaUIElement rowCellUIElement = rowChildElement as RowCellAreaUIElement; if (rowCellUIElement == null) continue; foreach (UIElement rowCellChildElement in rowCellUIElement.ChildElements) { cellElement = rowCellChildElement as CellUIElement; if (cellElement == null) continue; if (cellElement.Rect.Contains(currentPoint)) { UltraGridCell cell = (UltraGridCell)cellElement.GetContext(typeof(UltraGridCell)); if (cell != null) return cell.Column; } } } } }
Hi Ken,
The only reason this would not work is if your currentPoint is wrong.
Where are you getting this point from?
The point you pass in to ElementFromPoint has to a point in grid coordinates. If you are getting this point from the Drag/Drop events, then it will be in screen coords and you have to use PointToClient to convert it.
I was doing this.
Point currentPoint = grid.DisplayLayout.UIElement.CurrentMousePosition;so do this instead?Point currentPoint = grid.PointToClient(grid.DisplayLayout.UIElement.CurrentMousePosition);
Hi Mike,
Let me try to add in the PointToClient call and see if that works and get back to you.
thanks
-Ken