Mega Code Archive

 
Categories / Delphi / VCL
 

How to move rows and columns of a StringGrid by code

Title: How to move rows and columns of a StringGrid by code type TStringGridHack = class(TStringGrid) public procedure MoveColumn(FromIndex, ToIndex: Longint); procedure MoveRow(FromIndex, ToIndex: Longint); end; { The implementation of these methods simply consists of invoking the corresponding method of the ancestor: Die Implementierung dieser Methoden besteht nur darin, dass die Methoden des Vorfahren aufgerufen werden: } procedure TStringGridHack.MoveColumn(FromIndex, ToIndex: Integer); begin inherited; end; procedure TStringGridHack.MoveRow(FromIndex, ToIndex: Integer); begin inherited; end; // Example, Beispiel: procedure TForm1.Button1Click(Sender: TObject); begin TStringGridHack(StringGrid1).MoveColumn(1, 3); end;