Subject Re: [IBO] [Off Topic] Property Editor
Author Jay
Daniel wrote:

> please, i have a question about property editor.
>
> I'm developing a component that has a collection property and I'm
> trying to show the TCollection default property editor when user
> double click's the component ( the same property editor that appears
> when we, for example, double click's a listview or dbgrid's columns
> property ).
>
> I know how to write code to be executed when user double click's the
> components, but i don't how to access the TCollection property editor
> since it is created automatically by Delphi
>
> I would appreciate any help.
>
> thank you

Below are the basics. This creates a class 'TMyClass' containing a
property 'MyItems' which is a collection of collection items 'TMyItems'
that has one published property 'Caption' in this example. The rest is
up to you.

MyItems will show up in the property editor with a little ellipsis
button, which when clicked on opens up the little property edit window
containing just the one 'Caption' property.

In general you are better off on that topic to post here ->
forums.borland.com.borland.public.delphi.objectpascal

TMyClass = class;
//
TMyItem = class(TCollectionItem)
constructor Create(ACollection: TCollection); override;
destructor Destroy; override;
private
FCaption: string;
published
property Caption: string read FCaption write FCaption;
end;
//
TMyItems = class(TCollection)
constructor Create(AOwner: TMyClass);
private
FOwner: TMyClass;
function GetMyItem(Index: Integer): TMyItem;
procedure SetMyItem(Index: Integer; Value: TMyItem);
public
function Add(Value: string): TMyItem;
property MyItems[Index: Integer]: TMyItem read GetMyItem write
SetMyItem;
end;
//
TMyClass = class(TObject)
...
private
procedure SetMyItems(Value: TMyProps);
function GetMyItems: TMyProps;
published
MyItems: TMyItems read GetMyProp write SetMyProp;
end;

constructor TMyItems.Create;
begin
inherited Create(TMyItem); // this will create the collection
FOwner := AOwner; // this is where we belong to
end;

function TMyItems.GetMyItem;
begin
Result := TMyItem(inherited GetItem(Index));
end;

procedure TMyItems.SetMyItem;
begin
inherited SetItem(Index, Value);
end;

function TMyItems.Add;
begin
result := TMyItem(inherited Add);
result.Caption := Value;
end;

constructor TMyItem.Create;
begin
...
inherited Create(aCollection);
end;


destructor TMyItem.Destroy;
begin
...
inherited Destroy;
end;