我做了个ADO的过程(bde的我也做过):
procedure dbgSort(var dbg:TDBGridEh);
var i:Integer;
s:String;
begin
if not dbg.DataSource.DataSet.Active then exit;
s:='';
for i := 0 to dbg.SortMarkedColumns.Count-1 do
begin
if dbg.SortMarkedColumns.Title.SortMarker = smUpEh then
begin
if TADOQuery(dbg.DataSource.DataSet).FieldByName(dbg.SortMarkedColumns.FieldName).KeyFields='' then
s:=s+dbg.SortMarkedColumns.FieldName+' DESC,'
else
s:=s+TADOQuery(dbg.DataSource.DataSet).FieldByName(dbg.SortMarkedColumns.FieldName).KeyFields+' DESC,';
end
else
begin
if TADOQuery(dbg.DataSource.DataSet).FieldByName(dbg.SortMarkedColumns.FieldName).KeyFields='' then
s:=s+dbg.SortMarkedColumns.FieldName+' ASC,'
else
s:=s+TADOQuery(dbg.DataSource.DataSet).FieldByName(dbg.SortMarkedColumns.FieldName).KeyFields+' ASC,';
end;
end;
if s='' then exit;
delete(s,length(s),1);
TADOQuery(dbg.DataSource.DataSet).Sort:=s;
end;