Filter and sort data in a Windows Forms application

 

For the latest documentation on Visual Studio 2017, see Filter and sort data in a Windows Forms application on docs.microsoft.com. You filter data by setting the Filter property to a string expression that returns the desired records.

You sort data by setting the Sort property to the column name you want to sort on; append DESC to sort in descending order, or append ASC to sort in ascending order.

System_CAPS_ICON_note.jpg Note

If your application does not use BindingSource components, you can filter and sort data by using DataView objects. For more information, see DataViews.

  • Set the Filter property to the expression you want to return. For example, the following code returns customers with a CompanyName that starts with "B":

    No code example is currently available or this language may not be supported.

  • Set the Sort property to the column you want to sort on. For example, the following code sorts customers on the CompanyName column in descending order:

    No code example is currently available or this language may not be supported.

Bind controls to data in Visual Studio

Show: