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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...