Filtering problem

Good afternoon to all,

i have a strange situation with filter conditions.

In my grid i try to filter for all rows that have the value in col 5 empty ('') but with this code the grid will not be filtered:

procedure TFIMZG.CHK1Click(Sender: TObject);




if CHK1.Checked then


    with SG1.Filter.Add do



      Condition:='<>' + QuotedStr('');





Due the fact that in column 5 is stored a string rappresenting the date, i tried also with (the empty cells could have value zero)

Condition := '= 0';

In this case the grid is totaly empty, all rows are "cleared" .... included header (not formatted)

With any other value the filter work properly ....

All the rows with empty cell in column 5 is alway showed.

where i wrong ??

Actualy i resolve the problem setting the empity cells (alias no date information) to the 30/12/1899 and setting the filter condition with

with SG1.Filter.Add do



    Condition := '= 30/12/1899';


and it works, but seems to be a dirty solution ....

Thanks for all



PS : The filter works on the dispalyed cell text setted with GetDisplText event.

This event help us to display the text according our need, in this circustance we need to have the choice to apply the filter to the original text or the changed one.

I have recheched this here and I cannot see an issue to define a filter to retain empty cells in a given column.

Test code:

  fd: TFilterData;
  advstringgrid1.SaveFixedCells := false;
  advstringgrid1.Cells[5,5] := '';

  fd := advstringgrid1.Filter.Add;
  fd.Condition := '=""';
  fd.Column := 5;

  advstringgrid1.FilterActive := true;

This retains row 5 that was forced to have an empty cell in column 5.

If you use virtual cells, make sure to set filterdata.Data := fcVirtual and make sure to have your event OnGetDisplText to use the real row index to return the correct data instead of the display index.

Hi Bruno,

thank's for reply.

I made some test and i got for same previous conditions (empty cell value):

A - The filter work for

      Condition:='= ' or Condition:=' "" ' (Where " is shift 2)

      In both cases the grid shows only empty cells

B - The filter does not work for

      Condition:='= ' + QuotedStr('');

      Condition:='= '''' '; (Where '''' are 4 times ' )

This colud be possible due the fact in Unit AdvUnit in function:

function MatchStr(s1,s2:string;DoCase:Boolean):Boolean;

the the first code line is

if s1 = '""' then // (2 times shift 2)

        MatchStr := (s2 = '')

and work only with A

but if i change the first line with

if (s1 = '""') or (s1=QuotedStr('')) then

        MatchStr := (s2 = '')

this work with any condition for empty cells:

Condition:='= '

Condition:='= '''' ' (Two times shift 2 or 4 time ')

Condition:='= ' + quotedStr('');

Of course, this on my pcs.

Bruno, thank's for all



After the equal sign, there should be the value, so for empty strings, please set the condition to: 

fd.Condition := '=""';