BindingSource.Filter Property

 

Gets or sets the expression used to filter which rows are viewed.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

abstract Filter : string with get, set
override Filter : string with get, set

Property Value

Type: System.String

A string that specifies how rows are to be filtered. The default is null.

Typically used in complex data-binding scenarios, the Filter property allows you to view a subset of the DataSource. Only underlying lists that implement the IBindingListView interface support filtering.

When Filter is not null, the BindingSource passes this property to the underlying list. If you set this property during object initialization, the call will be deferred until after initialization is complete.

To form a filter value, specify the name of a column followed by an operator and a value to filter on. The accepted filter syntax depends on the underlying data source. If the underlying data source is a DataSet, DataTable, or DataView, you can specify Boolean expressions using the syntax documented for the DataColumn.Expression property.

The value of the Filter property affects the value of the Count property. Additionally, the Filter value will persist when the data source changes. To stop filtering the DataSource, call the RemoveFilter method.

The following example shows how to use the Filter property with a DataView. To run this example, paste the code into a Windows Form and call PopulateDataViewAndFilter from the form's constructor or Load event-handling method. Your form should import the System.Xml and System.IO namespaces.

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

.NET Framework
Available since 2.0
Return to top
Show: