Author: Tomas Rutkauskas I'm writing a TStringGrid descendant in which I would like to know, if the ColCount is being changed, because I have some other objects hidden in the component, that should be updated, when the ColCount changes. How can I accomplish that? Answer: You can try the following: 1 unit MyStringGrid; 2 3 interface 4 5 uses 6 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Grids; 7 8 type 9 TMyStringGrid = class(TStringGrid) 10 private 11 FColCount: Integer; 12 FOnColCountChanged: TNotifyEvent; 13 procedure SetColCount(Value: Integer); 14 protected 15 procedure ColCountChanged; virtual; 16 public 17 constructor Create(aOwner: TComponent); override; 18 published 19 property ColCount: Integer read FColCount write SetColCount default 5; 20 property OnColCountChanged: TNotifyEvent read FOnColCountChanged 21 write FOnColCountChanged; 22 end; 23 24 procedure register; 25 26 implementation 27 28 procedure register; 29 begin 30 RegisterComponents('Test', [TMyStringGrid]); 31 end; 32 33 constructor TMyStringGrid.Create(aOwner: TComponent); 34 begin 35 inherited Create(aOwner); 36 FColCount := 5; 37 end; 38 39 procedure TMyStringGrid.SetColCount(Value: Integer); 40 begin 41 if FColCount <> Value then 42 begin 43 FColCount := Value; 44 inherited ColCount := FColCount; 45 ColCountChanged; 46 end; 47 end; 48 49 procedure TMyStringGrid.ColCountChanged; 50 begin 51 52 {do dependend stuff here} 53 54 if Assigned(FOnColCountChanged) then 55 FOnColCountChanged(Self); 56 end; 57 58 end.