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

SfDataGrid getting highest visible row

Dears,
I'm working on the project based on the Syncfusion and I have the following issue to solve.
We have the SfDataGrid with some data and it is easily scrolled (obviously).
I'd like to detect the index of the row which is currently displayed on the top of the DataGrid.
Which method should I use?

Best regards,
Agata

1 Reply

SP Shobika Palani Syncfusion Team June 17, 2019 09:13 AM

Hi Agata, 

Thank you for using Syncfusion Products. 

We have analyzed your query to get the first visible row index in view. Your requirement can be achieved by using the VisibleLineInfoCollection as like below code snippet 

private void Button_Click(object sender, RoutedEventArgs e) 
        { 
            var visibleLines = this.sfdatagrid.GetVisualContainer().ScrollRows.GetVisibleLines(); 
            var firstVisibleRow = visibleLines.FirstOrDefault(line => line.Region == ScrollAxisRegion.Body); 
            var firstVisibleRowIndex = firstVisibleRow.LineIndex; 
            MessageBox.Show(firstVisibleRowIndex.ToString()); 
        } 

Please find sample for the same from the below link 

Sample Link: 

Please let us know, if you need any further assistance on this. 

Regards, 
Shobika. 


Loader.
Live Chat Icon For mobile
Up arrow icon