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
150
Reset Scrollbar Position
posted

I am working with an UltraGrid with a lot of rows. I have a vertical scrollbar dispalyed. If the users is viewing rows at the bottom of the grid and then saves their work the screen refreshes as expected, but the scrollbar jumps to the top of the grid. Is there any way you capture the scrollbars position and then reset it? I know I can scroll rows into view but that only gets me close depending on screen size and so on.

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    How you handle this depends on why the grid is scrolling to the top. When the user "saves the work", your code must be doing something that is causing the grid's data source to send a reset notification to the grid. This means the grid throws away everything and recreates an entirely new set of rows. The best thing to do would be to avoid these kinds of resets on your data source. In a typical application, it really should not be neccessary to cause a reset when saving data. 

    If that's not an option, then probably the best thing to do is store some kinf of key information about the first visible row. You can get the row using the ActiveRowScrollRegion.FirstRow property. You can try storing, and then re-setting the FirstRow property, but if I am right about the reset this won't work because the row will no longer be there. The old row will be destroyed and a new row representing the same row of data will be created. 

    So what you would have to do is store some kind of key information about the FirstRow. Then loop through the rows of the grid afterward to find that row and assign it as the FirstRow. You could wrap all of this in a BeginUpdate/EndUpdate block so that the grid doesn't paint during this process.

Children
No Data