Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
How To Keep Multiple Grids vertical Scroll Bars In Sync
posted

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.

Multi -grids

Parents
No Data
Reply
  • 21795
    Verified Answer
    Offline posted

    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.

    CAS-171932-B3Q9V9.zip
Children