Problema em ordenar DBGrid no delphi
sou meio novato no Delphi sei o básico...
E estou com problema ao ordenar os cadastros com ASC ou DESC.
No Banco de dados estou utilizando (IBQuery)+(UpdateSQL)+(DataSourse)
E estou com problema ao ordenar os cadastros com ASC ou DESC.
No Banco de dados estou utilizando (IBQuery)+(UpdateSQL)+(DataSourse)
Douglas
Curtidas 0
Respostas
Dirceu Morais
24/01/2020
No evento ontitleclick do dbgrid coloque:
Tente assim.
Não testei.
Begin
sua_tabela.IndexDefs.Update;
if sua_tabela.IndexName = Column.FieldName + '_ASC' then
begin
sIndexName := Column.FieldName + '_DESC';
Options := [ixDescending];
end
else
begin
sIndexName := Column.FieldName + '_ASC';
Options := [];
end;
if sua_tabela.IndexDefs.IndexOf(sIndexName) < 0 then
sua_tabela.AddIndex(sIndexName, Column.FieldName, Options);
sua_tabela.IndexName := sIndexName;
end;
Tente assim.
Não testei.
GOSTEI 0
Douglas
24/01/2020
No evento ontitleclick do dbgrid coloque:
Tente assim.
Não testei.
Begin
sua_tabela.IndexDefs.Update;
if sua_tabela.IndexName = Column.FieldName + '_ASC' then
begin
sIndexName := Column.FieldName + '_DESC';
Options := [ixDescending];
end
else
begin
sIndexName := Column.FieldName + '_ASC';
Options := [];
end;
if sua_tabela.IndexDefs.IndexOf(sIndexName) < 0 then
sua_tabela.AddIndex(sIndexName, Column.FieldName, Options);
sua_tabela.IndexName := sIndexName;
end;
Tente assim.
Não testei.
Tentei esse código mas ele não identifica o IndexName , sIndexName, IndexDefs, nem Options...
GOSTEI 0
Anderson Gonçalves
24/01/2020
select * from TABELA
order by CAMPO desc
order by CAMPO desc
GOSTEI 0