I'm trying to keep the scroll position synchronized between two separate grids that exist on a tab control. Thus only one of the grids is visible at a time. Setting grid.ActiveRowScrollRegion.ScrollPosition for the *non-visible* grid simply does not work in this scenario (unless I'm missing something, which I certainly hope is the case!).
For example, I can easily keep the grids synchronized when they are both visible on the form at the same time, no issues here and it's one line of code to acheive this.
However, executing the exact code with only one grid visbile and the other sitting on a different, non-selected tab, setting the grid.ActiveRowScrollRegion.ScrollPosition doesn't take. Stepping through the code shows that setting the value for the non-visible grid does not actually change its value, nor does it trigger the row scroll event for that hidden grid.
Now I can understand this could be deliberate, in that performance wise it might not make a lot of sense to scroll a grid that is not seen, but the problem I'm encountering is finding the right entry point to actually do the scroll if it can't happen in real time. For example, I can put the synchronization code behind a button, set the values equal to each other through that click event, and everything works fine (of course I don't want a button!).
I could utilize the Paint event of the non-visible grid, and when that fires set the ScrollPosition. However, then I have to implement some flags around to make sure the user can still manually scroll that grid without having its values reset to the values of the first (man, I hope that makes a even a little sense).
Putting this code in the VisibleChanged does not work, nor the SelectedTabChanged event in the tab control.
One last though, I have *ZERO* problems with column scrolling! Setting the columns scroll position through code works perfectly whether or not both grids are visible, which is what leads me to question if this is expected behavior.
Any help would be greatly appreciated.
There are quite a number of factors here that are unknown. Can you post a small sample project demonstrating this issue? If so, I would be happy to take a look and see if I can make it work, or determine if this is a bug.
Hi Mike,
Thanks for offering to take a look. I've uploaded a zip archive containing a very simple sample solution which demonstrates this issue. As is, with the grids on separate tabs, you will see that attempting to sync the rows will not work. However, if you drag the second grid out of the tab control to be visible on the form, it works fine. Stepping through the code, with the grids on the tabs, it becomes plain to see that setting the ScrollPosition property is just not holding.
I've only included a few events for the form just to show you the issue.
Thanks again.
Hi,
I ran your sample and it works fine for me. The scroll position of the second grid is updated just as it should be.
I, of course, am testing with the latest build, so I recommend that you download the latest Hot Fix and that should correct the problem.
Well that's very troubling, as I have installed the latest hotfix and this simple project does not work as you are describing it working for you. The grids simply do not stay synchronized by row...
Is it possible I missed a hotfix at some point? Looking at my system, I see only one hotifx applied to 2008 volume 3; yet I can't find on the Infragistics site a comprehensive list of hotfixes that have been released...?
Well, it's possible, though unlikely, that I am using a hot fix that you don't have access to, yet.
The latest Hot Fix is available on the web site: My Infragistics Keys and Downloads - Download Anything and Everything You Own
You might want to check the version of your assemblies against the version of the latest Hot Fix and make sure you have the latest one.
Mike,
FYI: I do have the latest hot fix installed. I have asked another developer (who is using the exact versions of the Infragistics controls I am) here to try the solution I posted and he is getting the same results as me; meaning, the second grid simply does not scroll.
Can you confirm, for my own sanity, that if you scroll the first grid all the way to the bottom, then switch to view 'tab2', the second grid has also scrolled to the bottom?
I'm completely baffled by the control's behavior here, and am assuming there is an issue with the ScrollPosition property...
Thanks again for your help.
This issue has been fixed. If you are encountering this issue and want to be added to the list of people who will be automatically notified when the fix is released, please submit a Developer Support issue (here) and reference Development Issue 16751.
For those who need a workaround and whose UltraGrids are visible, you can work around this issue by calling UltraGrid.Update() in between the calls setting the ScrollPosition.
Unfortunately, rywhee, because your UltraGrids are on tabs, the grid that is not on the selected tab is not visible, and this workaround will not work.
~Kim~
Okay, now I see the problem. When I tested this the first time, I just used the scroll button to scroll down a few rows and that works. But when I drag the thumb all the way down to the bottom, it's not working correctly. The second grid scrolls down only about 2 rows.
It does not appears that this has anything to do with the visibility of the grid. It's apparently caused by setting the ScrollPosition on the RowScrollRegion more than once in rapid succession.
For example, I put a button on the form and added this code to it:
this.ultraGrid1.ActiveRowScrollRegion.ScrollPosition = 60;
this works fine. But if I do this:
this.ultraGrid1.ActiveRowScrollRegion.ScrollPosition = 50;
The first line of code works and the second one is ignored. I guess this is because the grid is scrolling asynchronously and losing the second value.
I tried working around this using a BeginInvoke to call a method that scrolls the second grid, but that didn't work, either.
This seems like a bug to me and I am forwarding this thread over to Infragistics Developer Support so they can check it out. I'm attaching the simplified sample here.