哥们,用这个,通用!
procedure TMainForm.DBGridTitleBtnClick(Sender: TObject; ACol: Integer;
Column: TColumnEh);
var
DataSet: TDataSet;
begin
DataSet := Column.Field.DataSet;
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;
end;