Occurs when the contents of a cell in the filterbar changes.
[Visual Basic]
Public Event FilterChange As EventHandler
[C#]
public event EventHandler FilterChange
[Delphi]
public property FilterChange: EventHandler read remove_FilterChange write add_FilterChange;
Example
The following example raises the FilterChange event when the contents of the Filter Bar changes and AllowFilter property is set to False:
' Raised when the contents of the Filter Bar change.
Private Sub C1TrueDBGrid1_FilterChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles C1TrueDBGrid1.FilterChange
' Build our filter expression.
Dim sb As New System.Text.StringBuilder()
Dim dc As C1.Win.C1TrueDBGrid.C1DataColumn
For Each dc In Me.C1TrueDBGrid1.Columns
If dc.FilterText.Length > 0 Then
If sb.Length > 0 Then
sb.Append(" AND ")
End If
sb.Append((dc.DataField + " like " + "'" + dc.FilterText + "*'"))
End If
Next dc
' Filter the data.
Me.DataSet11.Tables(0).DefaultView.RowFilter = sb.ToString()
End Sub
· C#
// Raised when the contents of the Filter Bar change.
private void c1TrueDBGrid1_FilterChange(object sender, System.EventArgs e)
{
// Build our filter expression.
StringBuilder sb = new StringBuilder();
foreach(C1.Win.C1TrueDBGrid.C1DataColumn dc in this.c1TrueDBGrid1.Columns)
{
if( dc.FilterText.Length > 0 )
{
if( sb.Length > 0 )
{
sb.Append(" AND ");
}
sb.Append(dc.DataField + " like " + "'" + dc.FilterText + "*'");
}
}
// Filter the data.
this.dataSet11.Tables[0].DefaultView.RowFilter = sb.ToString();
}
· Delphi
private void C1TrueDBGrid1_FilterChange(sender: System.Object; e: System.EventArgs)
var
sb: StringBuilder;
dc: C1.Win.C1TrueDBGrid.C1DataColumn;
i: Integer;
begin
// Build our filter expression.
sb := StringBuilder.Create;
for I := 0 to this.c1TrueDBGrid1.Columns.Count – 1 do
begin
dc := this.c1TrueDBGrid1.Columns[i];
if ( dc.FilterText.Length > 0 ) then
begin
if ( sb.Length > 0 ) then
begin
sb.Append(' AND ');
end;
sb.Append(dc.DataField + ' like ' + '''' + dc.FilterText + '*''');
end;
end;
// Filter the data.
this.dataSet11.Tables[0].DefaultView.RowFilter := sb.ToString();
end;
For more information on this example, see the CustomFiltering sample located on http://helpcentral.componentone.com/ProductResources.aspx.
See Also
C1TrueDBGrid Class | C1TrueDBGrid Members | C1.Win.C1TrueDBGrid Namespace
Send comments about this topic to ComponentOne. Copyright © ComponentOne LLC. All rights reserved. |