Cita:
Empezado por DOS
Es que nunca use un TCustomADODataSet, no se como se configura. Hasta ahora solo utilice Ttable y Datasource.
|
Hola DOS.
TCustomADODataSet es la clase base de los componentes de datos ADO y no se usa directamente.
olbeup realiza el moldeado con el ancestro común de
TADOQuery y
TADOTable para que la propiedad
Sort pueda ser utilizada sea cual fuere al que el DBGRid este relacionado.
Tratándose de BDE, podrías usar un
TQuery:
Código Delphi
[-]
procedure TForm1.DBGrid1TitleClick(Column: TColumn);
{$J+}
const
PrvOrd: Boolean = False;
{$J-}
const
Orden: array[Boolean] of string=(' ASC',' DESC');
var
fName: string;
PrvInx: Integer;
begin
fName:= Column.Field.FieldName;
PrvInx:= Column.Index;
with DBGrid1.Columns[PrvInx].Title.Font do Style:= Style - [fsBold];
with TQuery(DBGrid1.DataSource.DataSet) do
begin
PrvOrd:= not PrvOrd;
Close;
SQL.Text:= 'SELECT * FROM TU_TABLA ORDER BY '+ fName + Orden[PrvOrd];
Open
end;
with DBGrid1.Columns[PrvInx].Title.Font do Style:= Style + [fsBold];
end;
Saludos.