RadGridView scroll position reset after Rebind() for WinForms

2 posts, 0 answers
  1. Joseph
    Joseph avatar
    9 posts
    Member since:
    Jun 2007

    Posted 01 Jul 2015 Link to this post

    This is a question specifically for WinForms but the question is the same as below: 

    http://www.telerik.com/forums/radgridview-scroll-position-reset-after-rebind 

    Basically, what object and parameters do I have to access within the RadGridView to get my scroll position, so that I can reset it to that position after a rebind.

  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 02 Jul 2015 Link to this post

    Hello Joseph,

    Here you are:
     RadScrollBarElement vScroll = radGridView1.TableElement.VScrollBar;
     int position = vScroll.Value;
     bool isMaxValue = position == vScroll.Maximum - vScroll.LargeChange + 1;
     radGridView1.TableElement.UpdateView();
      
     //rebind
      
     if (position > 0)
     {
         if (isMaxValue)
         {
             position = vScroll.Maximum - vScroll.LargeChange + 1;
         }
         radGridView1.TableElement.VScrollBar.Value = position;
     }

    I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

    Regards,
    Stefan
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top