<< Click to Display Table of Contents >> Navigation: Apollo VCL Components > Apollo VCL Component Reference > TApolloTable > TApolloTable Methods > DBFilter |
Declaration
function DBFilter: String;
Description
Extracts the current filter conditional expression. If there is no filter set but there is a query set with Query, the query expression is returned instead.
Return Value
The conditional xBase expression is returned as a string. A NULL string ('') is returned if there is no active filter or active query.
Delphi Example
procedure TForm1.Button1Click(Sender: TObject);
const
bFilterOn: WordBool = False;
begin
with ApTbl do
begin
if not bFilterOn then
begin
// Display filter dialog box for user to construct expression
FilterDlg( self.Handle,'STATE = "CA"','With Index Box',True );
// Filter set? If so, reset static bFilterOn flag
if DBFilter > '' then
begin
bFilterOn := True;
Button1.Caption := '&Reset';
GoTop;
end;
end
else
begin
// Otherwise, clear query & change caption back
bFilterOn := False;
Button1.Caption := '&Filter';
Query( '' );
GoTop;
end;
end;
end;
C++Builder Example
void __fastcall TForm1::Button1Click(TObject *Sender)
{
static bool bFilterOn = false;
if (!bFilterOn)
{
// Display filter dialog box for user to construct expression
ApTbl->FilterDlg( Form1->Handle, "STATE = 'CA'", "With Index Box", true );
// Filter set? If so, reset static bFilterOn flag
if (ApTbl->DBFilter() > "")
{
bFilterOn = true;
Button1->Caption = "&Reset";
ApTbl->GoTop();
}
}
else
{
// Otherwise, clear query & change caption back
bFilterOn = false;
Button1->Caption = "&Filter";
ApTbl->Query( "" );
ApTbl->GoTop();
}
}
See Also