问题
I made a database with paradox 7. The usual search I do is a syntax like this:
Table.Filter := 'Country=' + QuotedStr(Edit.Text);
This returns rows those country field is same as the entered text in edit. when I want to search for countries are beginning by "L" i use this syntax:
Table.Filter := 'Country=' + QuotedStr(Edit.Text + '*');
But how can I search for fields those are finished with "L"? this syntax does not work:
Table.Filter := 'Country=' + QuotedStr('*' + Edit.Text );
Thanks.
回答1:
You can use the OnFilterRecord event to carry out a customized filtering. With your example, maybe sth. like this:
procedure TForm1.Table1FilterRecord(DataSet: TDataSet; var Accept: Boolean);
var
s: string;
begin
Accept := False;
if not DataSet.FieldByName('Country').IsNull then begin
s := DataSet.FieldByName('Country').AsString;
Accept := Copy(s, Length(s), 1) = 'L';
end;
end;
来源:https://stackoverflow.com/questions/3989982/partial-search-in-tablebde