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

How to: Scroll to the Selected Row

7 Answers 2095 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Travis Parks
Top achievements
Rank 1
Travis Parks asked on 29 Apr 2010, 09:31 PM
Hello:

In our validation forms, we like to preselect the currently choosen item. I have the code written for selecting the corresponding BindingSource.Position. This automatically selects the row. How can I force the GridView to scroll to the currently selected row?

Thanks,
Travis

7 Answers, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 30 Apr 2010, 05:36 PM
Hello Travis Parks,

You can scroll to the concrete row by invoking the GridTableElement's method SrollToRow. You can use the following code snippet to achieve that:

GridTableElement tableElement = this.radGridView.CurrentView as GridTableElement;
GridViewRowInfo row = this.radGridView.CurrentRow;
 
if (tableElement != null && row != null)
{
    tableElement.ScrollToRow(row);
}

Kind regards,
Svett
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
R
Top achievements
Rank 1
answered on 27 Aug 2013, 05:30 PM
Is it possible to do this when using MVVM and data binding?
0
Ivan Petrov
Telerik team
answered on 28 Aug 2013, 11:29 AM
Hello Randy,

Thank you for writing.

As long as the grid is data bound and the actual data is loaded you can use the method proposed by my colleague. When bound RadGridView creates its own data items based on the data source and uses them for navigation.

I hope this will be useful. Should you have further questions, I would be glad to help.

Regards,
Ivan Petrov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Imane
Top achievements
Rank 1
answered on 10 Feb 2020, 07:54 PM
My problem is when i select many rows in radGridView (Telerik) and specialy when i select rows in the bottom of the RadGridView. the sroll move to the top. I need to fix the scroll position to be in the same position of the last selected row.
Thank you.
This is my code :
private void radGVToBeApproved_SelectionChanged(object sender, EventArgs e){this.radGVToBeApproved.SummaryRowsTop.Clear();this.radGVToBeApproved.SummaryRowsBottom.Clear();GridViewSummaryItem summaryItemCount = new GridViewSummaryItem(radGVToBeApproved.Columns[0].Name, "Total rows : {0}", GridAggregateFunction.Count);GridViewSummaryItem summaryItemSelectedRowsCount = new GridViewSummaryItem(radGVToBeApproved.Columns[0].Name, " Total selected rows : {0}", radGVToBeApproved.SelectedRows.Count.ToString());GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem(new GridViewSummaryItem[] { summaryItemCount, summaryItemSelectedRowsCount });this.radGVToBeApproved.SummaryRowsTop.Add(summaryRowItem);this.radGVToBeApproved.SummaryRowsBottom.Add(summaryRowItem);}
0
Imane
Top achievements
Rank 1
answered on 10 Feb 2020, 07:55 PM

Hello everybody,

I need your help,My problem is when i select many rows in radGridView (Telerik) and specialy when i select rows in the bottom of the RadGridView. the sroll move to the top. I need to fix the scroll position to be in the same position of the last selected row.
Thank you.

This is my code :

 private void radGVToBeApproved_SelectionChanged(object sender, EventArgs e)
        {
            this.radGVToBeApproved.SummaryRowsTop.Clear();
            this.radGVToBeApproved.SummaryRowsBottom.Clear();

            GridViewSummaryItem summaryItemCount = new GridViewSummaryItem(radGVToBeApproved.Columns[0].Name, "Total rows : {0}", GridAggregateFunction.Count);
            GridViewSummaryItem summaryItemSelectedRowsCount = new  GridViewSummaryItem(radGVToBeApproved.Columns[0].Name, "    Total selected rows : {0}", radGVToBeApproved.SelectedRows.Count.ToString());

            GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem(
                new GridViewSummaryItem[] { summaryItemCount, summaryItemSelectedRowsCount });

            this.radGVToBeApproved.SummaryRowsTop.Add(summaryRowItem);
            this.radGVToBeApproved.SummaryRowsBottom.Add(summaryRowItem);
           


        }


0
Nadya | Tech Support Engineer
Telerik team
answered on 13 Feb 2020, 02:38 PM

Hello Imane,

According to the provided code snippet, it seems that you clear the SummaryRowsTop/SummaryRowsBottom collections in the SelectionChanged event. Note that this causes updating the view of the grid and this is why the vertical scrollbar is reset to its default position. I can suggest you to store the vertical scrollbar value before performing a clear operation and the restore it after that:

private void RadGridView1_SelectionChanged(object sender, EventArgs e)
{
    int scrollValue = radGridView1.TableElement.VScrollBar.Value;
    this.radGridView1.SummaryRowsTop.Clear();
    this.radGridView1.SummaryRowsBottom.Clear();
    radGridView1.TableElement.VScrollBar.Value = scrollValue;
    //...
}

I hope this helps. Do not hesitate to contact me if you have other questions.

Regards,
Nadya
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Imane
Top achievements
Rank 1
answered on 13 Feb 2020, 06:20 PM
It work now .Thanks a lot for your help.
Tags
GridView
Asked by
Travis Parks
Top achievements
Rank 1
Answers by
Svett
Telerik team
R
Top achievements
Rank 1
Ivan Petrov
Telerik team
Imane
Top achievements
Rank 1
Nadya | Tech Support Engineer
Telerik team
Share this question
or