I'm trying to keep the vertical scroll position of two similar grids in sync. To do this, I am handling the AfterRowRegionScroll event of both grids like so: ultraGrid1.AfterRowRegionScroll += (s, e) => { ultraGrid2.EventManager.SetEnabled(GridEventIds.AfterRowRegionScroll, false); ultraGrid2.DisplayLayout.RowScrollRegions[0].ScrollPosition = e.RowScrollRegion.ScrollPosition; ultraGrid2.EventManager.SetEnabled(GridEventIds.AfterRowRegionScroll, true); };This works well for synchronizing the scrolling. Where I am having a problem, though, is when the grids resize. I have both grids anchored top/bottom to the form. If the grids are scrolled to the bottom and then are resized larger, I would assume they both would stay scrolled to the bottom, with just more rows showing (I have the grids' ScrollBounds set to 'ScrollToFill'). Instead one of the grids scrolls to the bottom fine, while the other scrolls past the bottom and leaves half the grid with empty space.
What it seems like is happening, is that when the grids resize, they fire off their AfterRowRegionScroll position with their old scroll position, rather than the new one. The causes the second grid that resizes, to resize the first grid with its old scroll position. This scrolls the first grid too far down and leaves the grid half empty.The grids resize correctly without the synchronization code in place, but I can't find a good place to disable/enable the events. Any ideas on how to keep the grids synced when resizing them?
I included a small sample project to illustrate the problem.
Hi,
I just wanted to let you know that we found a workaround for you. The ScrollPosition of the RowScrollRegion is not being updated before the AfterRowRegionScroll event fires. But the FirstRow property is. So all you have to do is use the FirstRow.Index.
void RegisterEvents() { ultraGrid1.AfterRowRegionScroll += (s, e) => { ultraGrid2.EventManager.SetEnabled(GridEventIds.AfterRowRegionScroll, false); ultraGrid2.DisplayLayout.RowScrollRegions[0].ScrollPosition = e.RowScrollRegion.FirstRow.Index; ultraGrid2.EventManager.SetEnabled(GridEventIds.AfterRowRegionScroll, true); }; ultraGrid2.AfterRowRegionScroll += (s, e) => { ultraGrid1.EventManager.SetEnabled(GridEventIds.AfterRowRegionScroll, false); ultraGrid1.DisplayLayout.RowScrollRegions[0].ScrollPosition = e.RowScrollRegion.FirstRow.Index; ultraGrid1.EventManager.SetEnabled(GridEventIds.AfterRowRegionScroll, true); }; }
Hello,
I have created a support case (CAS-54198-JFHDBY) for you and log this behavior in our tracking system as issue 56802.
When some other resolution is reached, I will contact you with this information.
Thank you.
This looks like a bug to me. I don't see why the grid should ever be scrolling such that there is empty space like this.
I am going to forward this thread to Infragistics Developer Support so they can check it out.
I tried not disabling the events and it did not fix the issue. Run my code sample with the event disabling commented out, scroll the grids to the bottom and then maximize the window. The second grid will be scrolled too far down, leaving half the grid empty.
Also, not disabling the events causes extra AfterRowRegionScroll events to fire. Programatically changing to scroll position causes this event to fire, which then causes a cyclical sequence of events (ie grid1 scrolls grid2, which then scrolls grid1, etc...). Scrolling happens asynchronously (correct me if I'm wrong here), which breaks the cycle after a few go arounds. So disabling the events is not really an option, unless there is an alternative solution to syncing the scrolling of grids...
Any other possible solutions to my problem?
Not disable the event and and refresh the grids seems to fix it:
ultraGrid1.AfterRowRegionScroll += (s, e) => { ultraGrid2.DisplayLayout.RowScrollRegions[0].ScrollPosition = e.RowScrollRegion.ScrollPosition; ultraGrid2.Refresh(); };