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 do I speed up search in GridDataBoundGrid control?

Platform: WinForms |
Control: GridDataBoundGrid(Classic)


The GridDataBoundGrid search can be speed up by finding the string through the grid data set records instead loop through the grid cells. The ArrayList maintains the filtered records which has the matching search string. Using the arraylist, you can find the record index of the matched string.


private GridRangeInfo[] FindAllFast(string search, int column)


ArrayList searchArray = new ArrayList();

CurrencyManager cm = (CurrencyManager)this.BindingContext[this.gridDataBoundGrid1.DataSource, this.gridDataBoundGrid1.DataMember];

int field = this.gridDataBoundGrid1.Binder.ColIndexToField(column);

for (int i = 0; i < cm.Count; ++i)


DataRowView drv = (DataRowView)cm.List[i];

String str = drv.Row[field].ToString();



ArrayList foundCells = new ArrayList();



this.Cursor = Cursors.WaitCursor;

int index = searchArray.IndexOf(search.ToUpper());

while (index > -1)


foundCells.Add(GridRangeInfo.Cell(index + 1, column));

index = searchArray.IndexOf(search.ToUpper(), index + 1);



catch { }



this.Cursor = Cursors.Default;


return (GridRangeInfo[])foundCells.ToArray(typeof(GridRangeInfo));



Private Function FindAllFast(ByVal search As String, ByVal column As Integer) As GridRangeInfo()

Dim searchArray As ArrayList = New ArrayList()

Dim cm As CurrencyManager = CType(Me.BindingContext(Me.gridDataBoundGrid1.DataSource, Me.gridDataBoundGrid1.DataMember), CurrencyManager)

Dim field As Integer = Me.gridDataBoundGrid1.Binder.ColIndexToField(column)

For i As Integer = 0 To cm.Count - 1

Dim drv As DataRowView = CType(cm.List(i), DataRowView)

Dim str As String = drv.Row(field).ToString()


Next i

Dim foundCells As ArrayList = New ArrayList()


Me.Cursor = Cursors.WaitCursor

Dim index As Integer = searchArray.IndexOf(search.ToUpper())

Do While index > -1

foundCells.Add(GridRangeInfo.Cell(index + 1, column))

index = searchArray.IndexOf(search.ToUpper(), index + 1)




Me.Cursor = Cursors.Default

End Try

Return CType(foundCells.ToArray(GetType(GridRangeInfo)), GridRangeInfo())

End Function

Please refer the sample in the below link which illustrates the above: http://websamples.syncfusion.com//samples/KB/Grid.Windows/Grid_Search/main.htm

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

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