Sorry -- posted this in the wrong location earlier. Someone please help, if you can!!
I am having difficulty finding how to access the ultragridcell location or the x,y coordinates of the top, left of the cell in the UltraGrid. Why isn't there a location property on the cell? I found an example for accessing the UI element and used the current mouse location out of desperation, and the element returns null when it's on the cell that I want to return!! Anyone have an example of how to do this or can someone even mention what property it is that I need to look at?
CODE THAT DOESN'T GET ME WHAT I'M LOOKING FOR:
UltraGrid grid = (UltraGrid)sender;
Infragistics.Win.UIElement elem = grid.DisplayLayout.UIElement.ElementFromPoint(new Point(grid.DisplayLayout.UIElement.CurrentMousePosition.X, grid.DisplayLayout.UIElement.CurrentMousePosition.Y));
That's why I said MouseEnterElement and not MouseEnter. :)
Thanks for your reply, but it looks like Hover & MouseEntyer event work the same, they fire only once.
Hi,
I don't think MouseHover is going to be very useful to you. This event fired when the mouse hovers over the control. So that means that if the mouse hovers over a cell in the grid, the event will fire. But this event will not fire again if you move the mouse over a different cell and hover it there. Since the event is control-based, it will only fire once for the entire control, and then it will not fire again until the mouse leaves the control and comes back in.
If you want to trap for mouse hovering over a cell, you would probably have to use MouseEnterElement and MouseLeaveElement and use your own timer to detect hovering.
Anyway, even though I don't think it will do you much good, if you want to get the cell in MouseHover, here's how you can do it...
private void ultraGrid1_MouseHover(object sender, EventArgs e) { UltraGrid grid = (UltraGrid)sender; UIElement element = grid.DisplayLayout.UIElement.LastElementEntered; if (element == null) return; UltraGridCell cell = element.GetContext(typeof(UltraGridCell)) as UltraGridCell; if (cell == null) return; Debug.WriteLine(cell.Text); }
HOWTO:UltraWinGrid Mouse Position and Cell Identification