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

Vertical Scroll position

4 Answers 345 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 2
Iron
Veteran
Iron
Rob asked on 15 Nov 2012, 09:52 PM
Hey Guys

Scratching my head over this one.. I have a grid populated by an SQL query.

On queries that require the vertical scroll bar to be shown , the first search displays with the Grid at the top of the results. ( scroll position at the top)

If I just hit search again without touching anything else... the scroll goes to the last row every time.

I have even tried setting this at the end of each search , but still the scroll appears at the end of the selection after the first populate.

 

Me.RadGridView1.TableElement.ScrollTo(0, 0)

 

 

I hate spending hours on something that is probably very easy !  It must be something I am doing to clear the Grid and repopulate it.. but haven't managed to find it!.

Any hints / thoughts?

Thanks

Rob

 

4 Answers, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 16 Nov 2012, 07:42 AM
Hello Rob,

There are a couple of things you can try here,
The first one is to set the select last added row to false, like so:
grid.MasterTemplate.SelectLastAddedRow = false;

or after you are changing the data, you can select again the first row from the current view,
this.grid.CurrentRow = this.grid.CurrentView.ViewInfo.Rows.FirstOrDefault();

or you can just set the datasource to null before starting the search and set it again once the search is done,
this.grid.DataSource = null;
// search or do anything
this.grid.DataSource = searchResultList;

If you have any other questions, please let me know.

Best Regards,
Emanuel Varga
WinForms MVP
0
Jack
Telerik team
answered on 20 Nov 2012, 02:00 PM
Hello Rob,

This issue appears because RadGridView synchronizes its current row with the underlying data source and its currency manager position. As Emanuel suggested you can change this behavior by setting the CurrentRow manually or by disabling it.

If you have further questions, do not hesitate to contact us.
 
All the best,
Jack
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
0
Rob
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 20 Nov 2012, 10:31 PM
Hey Guys

I think this has solved it.. I'm  flat out trying to complete the solution for the customer , so just added the code and did a quick test.

I think I may have seen it still scroll to the bottom once or twice over the last few days. So I may come back to this if I can reproduce it.

Thank you for your help :0)

Rob

0
Jack
Telerik team
answered on 22 Nov 2012, 04:51 PM
Hello Rob,

I am glad to hear that everything is OK now. Do not hesitate to contact us if you have further questions.
 
All the best,
Jack
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
GridView
Asked by
Rob
Top achievements
Rank 2
Iron
Veteran
Iron
Answers by
Emanuel Varga
Top achievements
Rank 1
Jack
Telerik team
Rob
Top achievements
Rank 2
Iron
Veteran
Iron
Share this question
or