How to: Scroll to the Selected Row

8 posts, 0 answers
  1. Travis Parks
    Travis Parks avatar
    7 posts
    Member since:
    Sep 2009

    Posted 29 Apr 2010 Link to this post

    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
  2. Svett
    Admin
    Svett avatar
    728 posts

    Posted 30 Apr 2010 Link to this post

    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.
  3. R
    R avatar
    3 posts
    Member since:
    Dec 2012

    Posted 27 Aug 2013 Link to this post

    Is it possible to do this when using MVVM and data binding?
  4. Ivan Petrov
    Admin
    Ivan Petrov avatar
    714 posts

    Posted 28 Aug 2013 Link to this post

    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 >>
  5. Imane
    Imane avatar
    3 posts
    Member since:
    Feb 2020

    Posted 10 Feb Link to this post

    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);}
  6. Imane
    Imane avatar
    3 posts
    Member since:
    Feb 2020

    Posted 10 Feb in reply to Imane Link to this post

    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);
               


            }


  7. Nadya
    Admin
    Nadya avatar
    187 posts

    Posted 13 Feb Link to this post

    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.
  8. Imane
    Imane avatar
    3 posts
    Member since:
    Feb 2020

    Posted 13 Feb in reply to Nadya Link to this post

    It work now .Thanks a lot for your help.
Back to Top