Skip to content

SwathiDhatchanamoorthi/how-to-scroll-to-a-specific-record-programmatically-in-winforms-datagrid

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

How to scroll to a specific record programmatically in WinForms DataGrid (SfDataGrid)

Scroll to a specific record in datagrid

You can programmatically scroll to a specific record in DataGrid using the SfDataGrid.TableControl.ScrollRows.ScrollInView method. You can get the row index of any record using the SfDataGrid.TableControl.ResolveToRowIndex method.

In the following example, data grid is scrolled to a record with OrderID value: 10680

C#

var record = this.sfDataGrid.View.Records.FirstOrDefault(item => (item.Data as OrderInfo).OrderID == 10680);
 
if (record != null)
{
    this.sfDataGrid.TableControl.ScrollRows.ScrollInView(this.sfDataGrid.TableControl.ResolveToRowIndex(record));
    this.sfDataGrid.TableControl.UpdateScrollBars();
}

VB

Dim record = Me.sfDataGrid.View.Records.FirstOrDefault(Function(item) (TryCast(item.Data, OrderInfo)).OrderID = 10680)
 
If record IsNot Nothing Then
 Me.sfDataGrid.TableControl.ScrollRows.ScrollInView(Me.sfDataGrid.TableControl.ResolveToRowIndex(record))
 Me.sfDataGrid.TableControl.UpdateScrollBars()
End If

About

This example explains about how to scroll to a specific record programmatically in datagrid

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 54.9%
  • Visual Basic .NET 45.1%