We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to scroll to a specific row/column programmatically in SfDataGrid?

Platform: Xamarin.Android |
Control: SfDataGrid

SfDataGrid allows you to scroll to a specific row/column programmatically. You can scroll vertically to a specific row index or horizontally to a specific column index or even diagonally to the specified row and column index. 

Scroll to row index

You can scroll programmatically to a particular row index using SfDataGrid.ScrollToRowIndex method by passing row index as parameter.

public class MainActivity : Activity
    Button rowScrollButton;
    Button columnScrollButton;
    Button rowColumnScrollButton;
    SfDataGrid dataGrid;
    ViewModel viewModel;
    protected override void OnCreate(Bundle bundle)
        LinearLayout layout = new LinearLayout(this);
        layout.SetPadding(0, 0, 10, 10);
        layout.Orientation = Orientation.Vertical;
        rowScrollButton = new Button(this);
        rowScrollButton.Text = "Scroll to RowIndex";
        rowScrollButton.Click += RowScrollButton_Click;
        columnScrollButton = new Button(this);
        columnScrollButton.Text = "Scroll to Columnindex";
        columnScrollButton.Click += ColumnScrollButton_Click;
        rowColumnScrollButton = new Button(this);
        rowColumnScrollButton.Text = "Scroll to RowColumnIndex";
        rowColumnScrollButton.Click += RowColumnScrollButton_Click;
        dataGrid = new SfDataGrid(this);
        viewModel = new ViewModel();
        dataGrid.ItemsSource = viewModel.ProductDetails;
    private void RowScrollButton_Click(object sender, EventArgs e)






Scroll to column index

You can scroll programmatically to a particular column index using SfDataGrid.ScrollToColumnIndex method by passing column index as parameter.


private void ColumnScrollButton_Click(object sender, EventArgs e)





Scroll to row and column index

You can scroll programmatically to a particular row and column index using SfDataGrid.ScrollToRowColumnIndex method by passing row and column index as parameters.


private void RowColumnScrollButton_Click(object sender, EventArgs e)
    dataGrid.ScrollToRowColumnIndex(6, 2);





Sample: Scroll specific row/column

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment
Apr 03, 2017
That's nice, but what about scrolling into row index on orientation changed?
Vimal Prabhu Manohkaran [Syncfusion]
Apr 25, 2017

Hi Stanic,

Thanks for using Syncfusion products. In Xamarin.Android the activity is restarted for the orientation changes. Hence a new activity is created each time the device orientation is changed. Hence your requirement can be achieved by either saving the bundle of the activity and resuming the bundle. Please refer the below link for more information.


Or you can listen to the configuration changed override by following the below steps.


1.       Enable the override OnConfigurationChanged( ) for your activity by including the below code in the Activity registration.

[Activity(Label = "GettingStarted", MainLauncher = true, Icon = "@drawable/icon",ConfigurationChanges = Android.Content.PM.ConfigChanges.Orientation | Android.Content.PM.ConfigChanges.ScreenSize)]

    public class MainActivity : Activity



2.       Hook the ScrollRows.Changed and ScrollColumns.Changed events inside the SfDataGrid.GridLoaded event handler. Please refer the below code snippet.

sfGrid.GridLoaded += SfGrid_GridLoaded;


private void SfGrid_GridLoaded(object sender, GridLoadedEventArgs e)


    var container = (sender as SfDataGrid).GetType().GetRuntimeProperties().FirstOrDefault(x => x.Name.Equals("VisualContainer")).GetValue(sfGrid) as VisualContainer;

    container.ScrollRows.Changed += ScrollRows_Changed;

    container.ScrollColumns.Changed += ScrollColumns_Changed;



3.       Now inside the ScrollRows.Changed and ScrollColumns.Changed event handlers, get the row and column index  currently in view by using the below code.

private void ScrollColumns_Changed(object sender, ScrollChangedEventArgs e)


    columnIndex = (sender as PixelScrollAxis).GetVisibleLines().FirstBodyVisibleIndex;



private void ScrollRows_Changed(object sender, ScrollChangedEventArgs e)


    rowIndex = (sender as PixelScrollAxis).GetVisibleLines().FirstBodyVisibleIndex;


Please note that the rowIndex and columnIndex are global variables.

4.       Now inside the OnConfigurationChanged ( ) override call the SfDataGrid.ScrollToRowColumnIndex( ) method to maintain the scrolled positions upon orientation changes. Please refer the below code snippet.

public override void OnConfigurationChanged(Configuration newConfig)



    this.sfGrid.ScrollToRowColumnIndex(rowIndex, columnIndex);


Vimal Prabhu

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile