该过程代码如下:
procedure TSysLookupFM.BtnFilterClick(Sender: TObject);
begin
EdtFilter.SetFocus;
with FField.LookupDataSetdo
begin
Filtered := False;
Filter := '';
if Trim(EdtFilter.Text) <> '' then
begin
Filter := '(';
Filter := Filter + Fields[1].FieldName + ' like ' + QuotedStr(Trim(EdtFilter.Text) + '%');
Filter := Filter + ' or ' + Fields[1].FieldName + ' like ' + QuotedStr('%' + Trim(EdtFilter.Text) + '%');
Filter := Filter + ' or ' + Fields[1].FieldName + ' like ' + QuotedStr('%' + Trim(EdtFilter.Text));
Filter := Filter + ')';
if FieldCount > 4 then
begin
Filter := Filter + ' and ' + Fields[4].FieldName + ' = 0 ';
end;
end else
begin
if FieldCount > 4 then
begin
Filter := Fields[4].FieldName + ' = 0 ';
end;
end;
Filtered := True;
BtnYes.Enabled := not IsEmpty;
end;
end;