Jump to content

How to view or make dbgrid filters invisible in real time?


eduardosuruagy

Recommended Posts

How to view or make dbgrid filters invisible in real time? I did a routine for this but when the dbgrid scroll is all to the right side of the video the filters are misaligned.

procedure TFrameMasterListener.BtnFilterClick (Sender: TObject);
var I: Integer;
begin
  if BtnFiltro.Tag = 0 then
  begin
    dbgrid_cadastro2.Columns.BeginUpdate;
    for I: = 0 to dbgrid_cadastro2.Columns.Count - 1 of
      if not dbgrid_cadastro2.Columns .Filtering.Enabled then
      begin
        if dbgrid_cadastro2.Columns .Tag = 0 then
        begin
          dbgrid_cadastro2.Columns .Filtering.Editor: = TUniEdit (Self.FindComponent ('edit _' + dbgrid_cadastro2.Columns.Items .FieldName));
          dbgrid_cadastro2.Columns .Filtering.Enabled: = True;
        end;
      end;

    dbgrid_cadastro2.Columns.EndUpdate;
    BtnFiltro.Tag: = 1;
  end
  else if BtnFiltro.Tag = 1 then
  begin
    dbgrid_cadastro2.Columns.BeginUpdate;
    for I: = 0 to dbgrid_cadastro2.Columns.Count - 1 of
      if dbgrid_cadastro2.Columns .Filtering.Enabled then
      begin
        dbgrid_cadastro2.Columns .Filtering.Editor: = nil;
        dbgrid_cadastro2.Columns .Filtering.Enabled: = False;
      end;

    dbgrid_cadastro2.Columns.EndUpdate;

    if CDCadastro.Active then
    begin
      CDCadastro.Filter: = '';
      CDCadastro.Filtered: = False;
    end;

    BtnFilter.Tag: = 0;
  end;
end;

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...