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));
Hi,
What exactly are you trying to do here?
You starting off by saying that you want to get the location of a cell in the grid. But the code you listed here does exactly the reverse - it gets a cell from a location.
To get the location of a cell, you would use the GetUIElement method on the cell to get it's UIElement. This may be null if the cell is not currently visible on the screen. If it's not null, you can get the Rect of the UIElement.
To get a cell from a location, you can use the code you have here. Except I'm not sure why you are using CurrentMousePosition. This might be a problem if those coordinates are not in the right system. ElementFromPoint takes client coords, not screen coords. If you want to get a cell from a point, I recommend checking out the Infraistics KB. There are lots of articles on how to do this sort of thing.
Knowledge Base Results - ElementFromPoint
HOWTO:UltraWinGrid Mouse Position and Cell Identification
I am trying to get the "Location" or X,Y cooridnates of the cell at its absolute position so that I know where to position a popup over that cell.
Again, there's not PointToClient() method, so that's useless. I'm getting closer but still not there with:
UltraGrid grid = ((UltraGrid)sender); CellUIElement element = (CellUIElement)e.Cell.GetUIElement(grid.ActiveRowScrollRegion, grid.ActiveColScrollRegion); Point p = new Point(); p = grpSalesOrder.PointToClient(p); int x = element.RectInsideBorders.X + grid.Location.X + p.X; int y = element.RectInsideBorders.Y + grid.Location.Y + p.Y; frmPopup frm = new frmPopup(x, y);
grpSalesOrder being the first control that I can find with a PointToScreen() call. Which returns negative values (not sure why yet, still researeching).
I'm not usually a UI developer so this is all a bit new for me.
So that's my question, how do I get the absolute X,Y position of the cell??????
Thanks for your reply, but it looks like Hover & MouseEntyer event work the same, they fire only once.
That's why I said MouseEnterElement and not MouseEnter. :)
Hello
I have an ultrawingrid. I have an MouseEnterElement event. I have a debug breakpoint on this event and I was surprised to see that this event fires in an infinite loop , i had to remove the breakpoint to actually stop it. Why is it so?
I am not sure if it was an infinite loop or number of rows * number of columns times. But still why so?
another question-->
on the mouseenterelement event , I want to get the current row , get the id value (this is a column in the grid row) then fetch the details from the database.
grid.activerow is null. How can I get the current row on which the mouse has entered?
Thanks
Janki
Hi Janki,
jsharpc said: I have an ultrawingrid. I have an MouseEnterElement event. I have a debug breakpoint on this event and I was surprised to see that this event fires in an infinite loop , i had to remove the breakpoint to actually stop it. Why is it so? I am not sure if it was an infinite loop or number of rows * number of columns times. But still why so?
I've used a breakpoint in this event many time, and I have never seen the event fire in an infinite loop. Of course, if you put a breakpoint in this event and then you continue to run your application and the application happens to appear under the current position of the mouse, then the grid will get a MouseMove message and the event will fire again. So you need to make sure the mouse point is out of the way.
jsharpc said: on the mouseenterelement event , I want to get the current row , get the id value (this is a column in the grid row) then fetch the details from the database. grid.activerow is null. How can I get the current row on which the mouse has entered?
You can't use the ActiveRow. ActiveRow is nothing to do with the current position of the mouse. You can get the row using the UIElements.
private void ultraGrid1_MouseEnterElement(object sender, UIElementEventArgs e) { RowUIElement rowUIElement = e.Element.GetAncestor(typeof(RowUIElement)) as RowUIElement; if (rowUIElement != null) { UltraGridRow row = rowUIElement.Row; } }
In ultrawingrid, when i double click the cell i need to place the cursor exactly where i double clicked.
Now when i double click the cell the cursor is placed in the end of the text. I done this with the help of placing the below code in the doubleclickcell event of the grid.
Grid.PerformAction(UltraGridAction.EnterEditMode) Dim editor As EmbeddableEditorBase = Me.Grid.ActiveCell.EditorResolved
editor.SelectionStart = editor.TextLength editor.SelectionLength = 0
Please let me know how to place the cursor anywere between the text where i double click.
Thank you for the reply.
There's no easy (or even reasonable, in my opinion) way to do this, because you cannot determine the selection position in a TextBox or other grid cell from a point.
The way the grid handles this internally, when you single-click on a cell, is that it fakes it by waiting until the cell has entered edit mode and then it uses the Winfows API to send a MouseDown message to the TextBox at the same point. So you could try to take the same approach, but it would be very tricky.