Subject Re: [IBO] Indicating 'grid with search criteria'
Author Geraldo Lopes de Souza
""Yagi"" <yagi@...> escreveu na mensagem
news:003101c0da61$c645f410$0201a8c0@......
> Hi,
>
> Is ther a way to remind user that he put some search criteria into his
> query?
> I mean user put some search criteria, forgot about it and next he was
> thinking where were his records.
>
> Yagi
>

The only generic way I found to show to the user the criteria that he has
applied was to have ordinary IBO controls in my form so I can look for
SearchBuffer property to know if there is a search criteria for the control.
I also use Grids but I use the others controls too. I pass the form to the
function below and it will recursively search for controls and build the
actual search criteria.

function IBOSearchCriteria(Ctrl: TWinControl): string;
var
SearchCriteria : string;

procedure AddToSearchCriteria(DisplayName: string; SearchBuffer: string);
begin
SearchCriteria := SearchCriteria + Format('%s:%s ', [DisplayName,
SearchBuffer]);
end;

procedure RecursiveLoop(Ctrl: TWinControl);
var
I: Integer;
begin
for I := 0 to Ctrl.ControlCount - 1 do
begin
if Ctrl.Controls[I] is TIB_CustomEdit then
begin
if (Ctrl.Controls[I] as TIB_CustomEdit).SearchBuffer <> '' then
AddToSearchCriteria((Ctrl.Controls[I] as
TIB_CustomEdit).Field.DisplayName,
(Ctrl.Controls[I] as TIB_CustomEdit).SearchBuffer);
end
else
if Ctrl.Controls[I] is TIB_CustomMemo then
begin
if (Ctrl.Controls[I] as TIB_CustomMemo).SearchBuffer <> '' then
AddToSearchCriteria((Ctrl.Controls[I] as
TIB_CustomMemo).Field.DisplayName,
(Ctrl.Controls[I] as TIB_CustomMemo).SearchBuffer);
end
else
if Ctrl.Controls[I] is TIB_CustomListBox then
begin
if (Ctrl.Controls[I] as TIB_CustomListBox).SearchBuffer <> '' then
AddToSearchCriteria((Ctrl.Controls[I] as
TIB_CustomListBox).Field.DisplayName,
(Ctrl.Controls[I] as TIB_CustomListBox).SearchBuffer);
end
else
if Ctrl.Controls[I] is TIB_CustomComboBox then
begin
if (Ctrl.Controls[I] as TIB_CustomComboBox).SearchBuffer <> '' then
AddToSearchCriteria((Ctrl.Controls[I] as
TIB_CustomComboBox).Field.DisplayName,
(Ctrl.Controls[I] as TIB_CustomComboBox).SearchBuffer);
end
else
if Ctrl.Controls[I] is TIB_CustomCheckBox then
begin
if (Ctrl.Controls[I] as TIB_CustomCheckBox).SearchBuffer <> '' then
AddToSearchCriteria((Ctrl.Controls[I] as
TIB_CustomCheckBox).Field.DisplayName,
(Ctrl.Controls[I] as TIB_CustomCheckBox).SearchBuffer);
end
else
if Ctrl.Controls[I] is TIB_CustomRadioGroup then
begin
if (Ctrl.Controls[I] as TIB_CustomRadioGroup).SearchBuffer <> ''
then
AddToSearchCriteria((Ctrl.Controls[I] as
TIB_CustomRadioGroup).Field.DisplayName,
(Ctrl.Controls[I] as TIB_CustomRadioGroup).SearchBuffer);
end;

if Ctrl.Controls[I] is TWinControl then
if (Ctrl.Controls[I] as TWinControl).ControlCount > 0 then
RecursiveLoop(TWinControl(Ctrl.Controls[I]));
end;
end;

begin
SearchCriteria := '';
RecursiveLoop(Ctrl);
Result := SearchCriteria;
end;