ComponentOne True DBGrid for .NET (2.0) Search HelpCentral 

Filtering Data in DataSets

In some cases, you might want to filter the underlying recordset by limiting the number of items in a given field or fields. With the True DBGrid, this is a very simple two-step process. By using the FilterBar and AllowFilter properties, and entering the filter text appropriately, the number of field entries can be reduced almost effortlessly. When the FilterBar property of a C1TrueDBGrid control is set, a blank row with a gray separator line appears directly above the uppermost data row in the grid.

Next, in order to implement the filter in the grid, set the AllowFilter property to be set to True, which will tell the grid to implement the filtering process. If the FilterBar and AllowFilter properties are both set to True, the Filter Bar will appear in the grid and the grid will also handle automatically the handling of the DataSet. 

In the event that you would prefer to handle the filtering process yourself, leaving the AllowFilter property as False will not implement the grid’s automatic filter. In order to create a filter, the FilterChange event, must be used to manually sort the data. This event fires whenever there the user changes the state of the Filter Bar. 

In this event a handler would have to be created which filters the dataset for each character the user enters. For example, if the user would happen to type a "B" into the filter bar cell, the underlying dataset would have to be limited to just those column items whose values start with the letter B. If the user then extended the filter to "BR", then the list would have to be reduced to only those whose values that start with BR.

 


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.