Mega Code Archive

 
Categories / Delphi / ADO Database
 

How to move Columns in a TDBGrid

Title: How to move Columns in a TDBGrid type THackAccess = class(TCustomGrid); { THackAccess Is needed because TCustomGrid.MoveColumn is protected and you can't access it directly. } // In the implementation-Section: procedure MoveDBGridColumns(DBGrid: TDBGrid; FromColumn, ToColumn: Integer); begin THackAccess(DBGrid).MoveColumn(FromColumn, ToColumn); end; Usage Example: procedure TForm1.Button1Click(Sender: TObject); begin MoveDBGridColumns(DBGrid1, 1, 2) end;