Application #34. DataGrid Sorting and Filtering

This sample demonstrates how to sort and filter data being displayed in a Windows Forms DataGrid control. First ADO.NET is used to retrieve product information from a SQL Server (or MSDE) database. The data is loaded into a DataSet object, and the grid is populated by binding it to the DataSet object. ADO.NET is also used to filter the data. When the user clicks the Filter button, a DataView object is used to show only specified rows in the DataGrid control. The user can sort the data by clicking any column heading in the DataGrid control. Figure 4-9 shows the DataGrid Sorting and Filtering application running, after the user has clicked the Filter button.

Figure 4-9. DataGrid Sorting and Filtering ...

Get 101 Microsoft® Visual Basic® .NET Applications now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.