4

I was wondering if there is a way to add custom method to already existing/included class component in Delphi Pascal.

I would like to use this to rotate StringGrid like this:

StringGridn.rotate(angle);

instead of:

rotate(StringGridn, angle);

Thanks for advice :)

Fabrizio
  • 7,603
  • 6
  • 44
  • 104
schullzroll
  • 168
  • 13

1 Answers1

13

You can use helpers like in example below, see Class and Record Helpers (Delphi).

type  
  TStringGridHelper = class helper for TStringGrid
    procedure Rotate(Angle: Single);
  end;

procedure TStringGridHelper.Rotate(Angle: Single);
begin
  { your implementation }
  Rotate(Self, Angle);  
end;

and then just call

StringGridn.Rotate(Angle);
Triber
  • 1,525
  • 2
  • 21
  • 38