數據源為adoQuery
1、首先設置dbGridEh里需要排序的字段的Title->Titlebutton屬性為true
2、設置dgGridEh的optionsEh->dbhautoSortMarking屬性為true
3、在dbGridEh的ontitleButtonClick事件里面判斷。
PRocedure Tfrmmain.dbgGridEh1TitleBtnClick(Sender: TObject; ACol: Integer;
  Column: TColumnEh);
begin
      if column.Title.SortMarker=smdowneh then
         adoQuery1.Sort :=column.FieldName
   else
         adoQuery1.Sort :=column.FieldName +' DESC';
end;
新聞熱點
疑難解答