delphi-2009

Is possible to set filter option in SMDBGrid to CaseInsensitive?


I have SMDBGrid component with show filter bar option set to true, but filter just working in case-sensitive mode

1.Try with lower case

2.Try with upper case

I have tried to insert the code in SMDBgrid.pas like this

procedure TSMDBGrid.ApplyFilter;
var
  TempCol: Integer;
begin
  if (eoFilterAutoApply in ExOptions) then
  begin
    TempCol := LeftCol;
    BeginUpdate;
    try
      if DataLink.Active then
      begin
        DataLink.DataSet.CheckBrowseMode;
        DataLink.DataSet.Filtered := False;
        DataLink.DataSet.OnFilterRecord := nil;
        DataLink.DataSet.OnFilterRecord := OnFilterRecord;
        DataLink.DataSet.FilterOptions := [foCaseInsensitive]; <-- this the inserted code
        DataLink.DataSet.Filtered := not FilterIsEmpty();//True;
      end;
    finally
      LeftCol := TempCol;
      EndUpdate;
    end;
  end;

  if Assigned(OnFilterChanged) then
    OnFilterChanged(Self);
end;

But no luck, Is posible filter the record ignoring the case?

PS: I use Delphi 2009


Solution

  • Maybe this is not actual any more, but put in the grid's OnFilterApply event this: Accept:= Pos(UpperCase(FilterString), UpperCase(Field.AsString))>0;