unit LexColumnCollection; interface uses Messages, Windows, SysUtils, Classes, Controls, Forms, Menus, Graphics; type { TLexControl } TLexControl = class; TLexColumn = class(TCollectionItem) private // Main componet access is in TCollectionItem FText: string; procedure SetText(const Value: string); protected function GetDisplayName: string; override; // gain parent data example public constructor Create(Collection: TCollection); override; destructor Destroy; override; procedure Assign(Source: TPersistent); override; published property Text: string read FText write SetText; end; TLexColumns = class(TCollection) private LexControl: TLexControl; // Main componet access if needed function GetItem(Index: Integer): TLexColumn; procedure SetItem(Index: Integer; Value: TLexColumn); protected function GetOwner: TPersistent; override; public constructor Create(LexControl: TLexControl); function Add: TLexColumn; property Items[Index: Integer]: TLexColumn read GetItem write SetItem; default; end; TLexControl = class(TCustomControl) private FColumns: TLexColumns; FColumnIndex: Integer; // current panel procedure SetColumns(Value: TLexColumns); procedure SetColumnIndex(const Value: Integer); Protected procedure DblClick; override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; procedure Notification(AComponent:TComponent; Operation: TOperation); override; published property Columns: TLexColumns read FColumns write SetColumns; property ColumnIndex: Integer read FColumnIndex write SetColumnIndex; end; procedure Register; implementation //uses Consts; procedure Register; begin RegisterComponents('Lex', [TLexControl]); end; { TLexColumn } constructor TLexColumn.Create(Collection: TCollection); begin inherited Create(Collection); end; procedure TLexColumn.Assign(Source: TPersistent); begin if Source is TLexColumn then begin Text := TLexColumn(Source).Text; end else inherited Assign(Source); end; function TLexColumn.GetDisplayName: string; begin Result := Text; if Result = '' then Result := inherited GetDisplayName; end; procedure TLexColumn.SetText(const Value: string); begin if FText <> Value then begin FText := Value; Changed(False); end; end; destructor TLexColumn.Destroy; begin inherited; end; { TLexColumns } constructor TLexColumns.Create(LexControl: TLexControl); begin inherited Create(TLexColumn); LexControl := LexControl; end; function TLexColumns.Add: TLexColumn; begin Result := TLexColumn(inherited Add); end; function TLexColumns.GetItem(Index: Integer): TLexColumn; begin Result := TLexColumn(inherited GetItem(Index)); end; function TLexColumns.GetOwner: TPersistent; begin Result := LexControl; end; procedure TLexColumns.SetItem(Index: Integer; Value: TLexColumn); begin inherited SetItem(Index, Value); end; { TLexControl } constructor TLexControl.Create(AOwner: TComponent); begin inherited Create(AOwner); FColumns := TLexColumns.Create(Self); end; destructor TLexControl.Destroy; begin FColumns.Free; inherited Destroy; end; procedure TLexControl.SetColumns(Value: TLexColumns); begin FColumns.Assign(Value); end; procedure TLexControl.SetColumnIndex(const Value: Integer); begin if FColumnIndex <> value then begin FColumnIndex := Value; end; end; procedure TLexControl.Notification(AComponent: TComponent; Operation: TOperation); begin { if (operation=opremove) and (Acomponent=FImages) then SetImages(nil); if (operation=opremove) and (Acomponent=FSmallImages) then SetSmallImages(nil); } end; procedure TLexControl.DblClick; begin inherited; If csDesigning in ComponentState then //Collection editor be invoked from hear end; end.