Sort columns in DBGrid

Posted in Databases

Use the FieldName property of the DBGrid to set an index with the same name as the FieldName.

procedure TForm1.DBGrid1TitleClick(Column: TColumn);
begin
  (Column.Field.DataSet as TTable).IndexFieldNames:=Column.FieldName;
end;