Hi,
I am attempting to write code where the user can select/drag some rows and drop it to another area in the same grid. What I would like to happen is to highlight somehow the destination row (preferably by change the border) so that the user can visually see where they are dropping the data. So as the selection is dragged over a number rows then each row is highlighted on enter and returns back to it normal state on leave.
How would I achieve this? Anybody have any examples?
Thanks in advance.
Nish
Thank you Mike!!!
It all works perfectly now.
Helen.
Hi Helen,
How you reset the color depends on how you are setting the color. If you are applying an Appearance to the row or cells, then you need to reset those same appearance properties on the same row or cell.
It's typically best practice to use the InitializeRow event for this kind of thing. The event fires any time any value in any cell of the row changes, so that alleviates the need to loop.
But if you are coloring a cell on MouseMove, then the best thing to do is probably to store the row(s) that you colored in a variable, and then you can get back to that row any time you want to reset the appearance.
Hi Mike,
your code works beautifully, thank you! I have just one more question.
As you suggested earlier in this post, I am changing the background color for the rowUnderMouse. But I can not figure out how to reset previously highlighted rows back to the original color. I ended up looping through all the rows in a grid, but this affected the performance.
Is there a better way?
Thank you,
No, there haven't been any changes in this area. But it's really not hard at all to determine where the row will be dropped. The article I posted a link to above gives you the code. The only thing you have to do is convert from screen coordinates to control coordinates. And that's just a single method call.
void ultraGrid1_DragOver(object sender, DragEventArgs e) { var grid = (UltraGrid)sender; Point pointInScreenCoords = new Point(e.X, e.Y); Point pointInControlCoords = grid.PointToClient(pointInScreenCoords); UIElement element = grid.DisplayLayout.UIElement.ElementFromPoint(pointInControlCoords); if (null != element) { UltraGridRow rowUnderTheMouse = element.GetContext(typeof(UltraGridRow)) as UltraGridRow; if (null != rowUnderTheMouse) Debug.WriteLine("The mouse is over row: " + rowUnderTheMouse.Index.ToString()); } }
I am using Infragistics version 13.1. I created a very simple form that lets users to move rows in UltraGrid around by dragging and dropping them.
The problem is - as the user above has mentioned - that it is hard to figure out where the record that is being dragged will be dropped.
Is there a built in capability for this now (it has been over 5 years since the original post, and things may have changed), or may be you can point me to a sample code that implements it.
Thank you in advance for your help.