I have an UltraWinGrid with several drag & drop events. In the _DragOver event, I'm drawing a rectangle around the current drop row (there are hidden rows between each row that allow the user to drop "between" two visible rows, so we highlight whether or not they are "on" the row or "between" rows). When I drag the row up into the header, the rectangle continues to be drawn, but I don't want it to be shown. How can I determine when I am over the header and not run any of my other code (drawing the rectangle, etc...)?
Thanks,
Ryan
Hi Ryan,
This should work for almost all cases, but there's one possibility that you are not accounting for. GetAncestor will only return a parent element. So if the uieOver is a RowUIElement, it won't work. This may not be a problem since the row is probably covered by cells, but it's probably a good idea to check if uieOver is a RowUIElement, too, just to be thorough. :)
Thanks Mike. That's exactly what I was doing.
I was doing this:Point pointInGridCoords = this.ultraGridVerifiedCars.PointToClient(new Point(e.X, e.Y));UIElement uieOver = this.ultraGridVerifiedCars.DisplayLayout.UIElement.ElementFromPoint(pointInGridCoords);if (uieOver != null) {...}
I added an extra check to the if statement:if (uieOver != null && uieOver.GetAncestor(typeof(RowUIElement)) != null) {...}
Looks like that is working. Thanks again.Ryan
Your code is probably detecting the row by using ElementFromPoint and then calling GetContext to get the UltraGridRow. The column header elements will return the first row in the collection as their context. So what you need to do is check for a RowUIElement before you call GetContext. ElementFromPoint might return a RowUIElement. If not, use GetAncestor to see if there is a RowUIElement in it's parent chain. If not, don't show your highlight because you are not over a row.