...move Columns in a TDBGrid?

Author: Thomas Stutz

Category: Database

type
  
THackAccess = class(TCustomGrid);

{
  THackAccess Is needed because TCustomGrid.MoveColumn is
  protected and you can't access it directly.

  THackAccess Braucht man, da TCustomGrid.MoveColumn in der
  Protected-Sektion steht und nicht direkt darauf zugegriffen werden kann.
}

// In the implementation-Section:

procedure MoveDBGridColumns(DBGrid: TDBGrid; FromColumn, ToColumn: Integer);
begin
  
THackAccess(DBGrid).MoveColumn(FromColumn, ToColumn);
end;


{Example/ Beispiel}

procedure TForm1.Button1Click(Sender: TObject);
begin
  
MoveDBGridColumns(DBGrid1, 1, 2)
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base