dbgrideh中按任意feild排序

                            用第三方控件
ehlib
例子: 注:bz 为一boolean类型变量
procedure Tform1.DBGridEhTitleBtnClick(Sender: TObject; ACol: Integer;
Column: TColumnEh);
begin
If bz then
begin
  TADOQuery(DBGridEh.DataSource.DataSet).Sort := Column.FieldName+' ASC';
    Column.Title.SortMarker := smUpEh;
    bz := False;
end
else
begin
  TADOQuery(DBGridEh.DataSource.DataSet).Sort := Column.FieldName+' DESC';
  Column.Title.SortMarker := smDownEh;
  bz := True;
end
end;  


                                

查看回复