Hi, i have a wingrid that is being refreshed on a timer which basically resets the current viewing area back to the top. I want to be returned right back to where i was before the refresh.(also saving/reloading) the layout of the grid
i tried this which doesn't quite work 100%
Does anyone have a recommendation on this?
using (MemoryStream s = new MemoryStream()) { int irow = ultraGridWatch.ActiveRowScrollRegion.ScrollPosition; int icol = ultraGridWatch.ActiveColScrollRegion.Position; ultraGridWatch.DisplayLayout.Save(s); s.Position = 0;
PerformMyRefreshFunction();
ultraGridWatch.DisplayLayout.Load(s, PropertyCategories.All); ultraGridWatch.ActiveRowScrollRegion.ScrollPosition = irow; ultraGridWatch.ActiveColScrollRegion.Position = icol;
}
Hi,
Allen Maizenberg said:The displaylayout.Load(Categories.ALL) was the problem. those categories included row and col scroll positions.
Actually, it does not. The layout cannot include the scroll positions.
I think what's probably happening here is that your code is setting the scroll position after you load the layout, but before the grid has painted. Then grid is then performing sorting or filtering asynchronously, which then changes the scroll position. So one way you could get around this is to call grid.Refresh() to force a paint after you load the layout, but before you set the scroll positions.
Another option would be to use a BeginInvoke to restore the scroll positions, instead of doing it synchronously.
apologies, i found the solution. setting and resetting the scroll positions worked fine. The displaylayout.Load(Categories.ALL) was the problem. those categories included row and col scroll positions.
so instead i called the displaylayout.load twice. once with (General) and again but with (SortedColumns). and i was able to preserve the things i needed, sorted cols, column position etc.