I wrote below unit for a sample component :
unit Test;
interface
uses
System.SysUtils, System.Classes, System.Variants, VCL.Dialogs;
type
TTest = class(TComponent)
private
fName: TStringList;
{ Private declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); Override;
destructor Destroy; override;
published
{ Published declarations }
property Names: TStringList read fName;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TTest]);
end;
{TTest }
constructor TTest.Create(AOwner: TComponent);
begin
inherited;
fName := TStringList.Create;
for i:= 1 to 100 do
fName.Add(IntToStr(i));
end;
destructor TTest.Destroy;
begin
fName.Free;
inherited;
end;
end.
Now when I install it on Delphi, in the Object Inspector I have a property named “Names”, I should double click on it then a dialog shows the TStringList’s items stored on Name.
I would like to make this property like Font.Name in other components (like TEdit and etc), when click on Name property , a list shows and user can select an item from it, then the item is assigned to the property and show as property value in the Object Inspector.
You need to write a property editor for your property. Here are some links for you to read as it’s not a simple answer:-
http://www.drbob42.com/delphi/property.htm
http://delphi.about.com/library/bluc/text/uc092501a.htm
http://www.delphicorner.f9.co.uk/articles/comps1.htm