Hi, I'm facing a problem about keeping multiple scroll bars from different grids in sycn.
I have implemented ability that when I expand a row in grid1, the row with same index in other grids will also be expanded. If they do not have child rows, I will change the row spacing after to make the space between the row and next row same as grid 1.
The problem is when I expand a row in grid 1(let's say this row has 3 child rows), if the row with same index in grid 2 also has 3 child row, then everything goes perfectly. But if there is not child row in grid2, in this case when I slide the scroll bar, the rows in these 2 grids are out of sync. Rows with different index may fall in same line.
Hello Grand,
Thank you for posting in our forum.
Right now there is no such build in functionality in the grid, allowing you to sync the scrolling of two grids. If your grids have the same rows structure, e.g. number of rows and number of child rows, what you can do is handle AfterRowRegionScroll of the grids. In the event handle you can set the scroll position of the active scroll region of both grids to the scrolled value. You can use code like this:
private void UltraGrid_AfterRowRegionScroll(object sender, RowScrollRegionEventArgs e)
{
if (sender.Equals(this.ultraGrid2))
ultraGrid1.ActiveRowScrollRegion.ScrollPosition = e.RowScrollRegion.ScrollPosition;
}
if (sender.Equals(ultraGrid1))
ultraGrid2.ActiveRowScrollRegion.ScrollPosition = e.RowScrollRegion.ScrollPosition;
If the two grids has different rows structure I am not sure if this is possible at all. Consider the grid you are scrolling / expanding has 20 child rows for let say first row. Consider also the second grid’s first row has no any child rows. Where should be scrolled the second grid if the first grid are visible only child rows, e.g. from sixth to tenth row?
Please check the attached sample project where I have implement synchronous scrolling of two grids with same rows structure as described above and let me know if you need any additional information.
Thank you for using Infragistics Controls.
Sorry. I just updated this topic and uploaded a new screenshot. Please take a look. Thanks.
Hello Grnd,
Yes, you are correct. The size of the scrollbar depends on the number of visible rows. And there is no way to control this by setting any public property or call a method of the grid. What I can suggest you, to synchronize the scrolling of the grids is to try to set the FirstRow of your RowScrollRegions to the row you need to be at the top of the visible rows.
Please let me know if this solves your issue.
Thanks a lot for your quick reply!
I will try the way you suggested and there is a secondary way I would like to try - I believe right now when user scrolls, the screen may change by percentage. I may need to step in some event and make this by certain value instead.
Still, I will try your suggestion first.
Again, thank you very much!