This is a migrated thread and some comments may be shown as answers.

RadGridView scroll position reset after Rebind() for WinForms

1 Answer 667 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Joseph
Top achievements
Rank 1
Joseph asked on 01 Jul 2015, 03:27 PM

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.

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 02 Jul 2015, 10:25 AM
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
Tags
GridView
Asked by
Joseph
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or