如题

解决方案 »

  1.   

    排序
    DBGrid1的onTitleClick
    var
      DataSet: TDataSet;
    begin
      {点击标题栏,排序}   
      
      DataSet := Column.Field.DataSet;
      if not DataSet.Active then exit;  if DataSet is TCustomADODataSet then
      with TCustomADODataSet(DataSet) do
      begin
        if (Pos(Column.Field.FieldName, Sort) = 1) and (Pos(' DESC', Sort) = 0) then
           begin
             Sort := Column.Field.FieldName + ' DESC';
           end
        else
           begin
             Sort := Column.Field.FieldName + ' ASC';
           end;
      end;
      

  2.   

    设置一下三个为True;
    titlebutton
    sortlocal
    dghautosorting
      

  3.   

    就是一楼的存储过程返回的数据集也可
    DataSet is TADOStoredProc