I have an ultragrid, in which user can re-arrange the index of rows by dragging and dropping. Suppose there are 50 rows, but only 20 rows are in the visible region. Now, I want to have a functionality that if user wants to drag row #1 to just above row #40, then as soon as he reaches the end of the visible region, the grid should scroll down automatically.
Hello Sumit,
Thank you for contacting Infragistics Developers Support.
To scroll the grid while performing drag and drop operation you need to check in DragOver event if the mouse pointer is reach the grid’s active scroll region top or bottom. If so force the grid to scroll up or down. You can use code like this in your DragOver event handler:
Point point = grid.PointToClient(new Point(e.X, e.Y));
if (point.Y < 20)
{
// Scroll up.
this.ultraGrid1.ActiveRowScrollRegion.Scroll(RowScrollAction.LineUp);
}
else if (point.Y > grid.Height - 20)
// Scroll down.
this.ultraGrid1.ActiveRowScrollRegion.Scroll(RowScrollAction.LineDown);
Please find attached a small sample solution implementing this approach.
Please let me know if you need any further assistance.
Hello Milko,Thank you for your support. The code provided by you is working fine, which almost serves my purpose. But as per my requirement, I need to rearrange the rows in single grid by dragging and dropping. After adding your code in my application, grid is scrolling automatically, but the scroll speed is very fast. This creates problems for me in the following scenario:Suppose there are 100 rows, and i want to move row #2 to row #75, and suppose there are 20 rows in the visible region. Now when I start dragging row #2, I reach the end of visible region, the grid starts scrolling down, but it scrolls so fast that I always reach the end of the rows, but ideally the scroll speed should be slower, so that I can stop scrolling when I see row #75.This is really important for my application that grid scrolls slower. Again Looking forward to have valuable feedback from your side.
I am just checking about the progress of this issue. Let me know if you need our further assistance on it.
Thank you for using Infragistics Components.