eYes
asked on
Name property
some code here:
type
TNoUsage = class(TPanel)
private
{ Private declarations }
fedit1: TEdit;
fedit2: TEdit;
fedit3: TEdit;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Sample s', [TNoUsage]);
end;
constructor TEdPanel.Create(AOwner: TComponent);
begin
inherited Create(aowner);
controlstyle := controlstyle - [csAcceptsControls];
fedit1 := tedit.create(aowner);
fedit1.parent := self;
fedit1.left := 5;
fedit1.top := 5;
fedit2 := tedit.create(aowner);
fedit2.parent := self;
fedit2.left := 5;
fedit2.top := 35;
fedit3 := tedit.create(aowner);
fedit3.parent := self;
fedit3.left := 5;
fedit3.top := 65;
end;
end.
when i put this component on the form, and select one of the three edits, in object inspector, the edit's name property is empty.
How to let IDE auto set edit's name? (such as Edit1).
TTabSheet can do so.
type
TNoUsage = class(TPanel)
private
{ Private declarations }
fedit1: TEdit;
fedit2: TEdit;
fedit3: TEdit;
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
published
{ Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Sample
end;
constructor TEdPanel.Create(AOwner: TComponent);
begin
inherited Create(aowner);
controlstyle := controlstyle - [csAcceptsControls];
fedit1 := tedit.create(aowner);
fedit1.parent := self;
fedit1.left := 5;
fedit1.top := 5;
fedit2 := tedit.create(aowner);
fedit2.parent := self;
fedit2.left := 5;
fedit2.top := 35;
fedit3 := tedit.create(aowner);
fedit3.parent := self;
fedit3.left := 5;
fedit3.top := 65;
end;
end.
when i put this component on the form, and select one of the three edits, in object inspector, the edit's name property is empty.
How to let IDE auto set edit's name? (such as Edit1).
TTabSheet can do so.
ASKER
"auto" ?
This becomes complicated as you need to create a component editor which has access to the form designer (IFormDesigner). This interface has (inherited from IDesigner) a method call UniqueName which returns a unique component name for the form it is designing.
Ciao, Mike
Ciao, Mike
ASKER
could u give me some samples?
Why are you concerned about their names. Setting the names to a value will only do things worse as you may get naming conflicts when inserting multiple TNoUsage's on your form...
If you dont need the name (and I'm sorry that I can't imagine what you need it for), then leave it blank !!!
Regards
If you dont need the name (and I'm sorry that I can't imagine what you need it for), then leave it blank !!!
Regards
I agree with KE and, unfortunately, I don't have a sample ready to post here. So I'd need to write one which will take an hour or more. Is it really worth the effort?
Ciao, Mike
Ciao, Mike
ASKER
i have 1 problem. when i put my TNoUsage on the form, change some edits' property in the TNoUsage and save the project then close all and open again,
i found delphi create 3 new edits and load
3 old, totally 6(!) edits in my TNoUsage.
i think if i can let IDE set edits' name maybe it will be correct. am i right?
sorry for my poor english.
i found delphi create 3 new edits and load
3 old, totally 6(!) edits in my TNoUsage.
i think if i can let IDE set edits' name maybe it will be correct. am i right?
sorry for my poor english.
When you create the Edit's set the owner to nil - like:
fedit1 := tedit.create(nil);
Create a destructor for the TNoUsage where you free these. This should remove the problem !
Regards
fedit1 := tedit.create(nil);
Create a destructor for the TNoUsage where you free these. This should remove the problem !
Regards
ASKER
i use tedit.create(aowner) because i want to let IDE show the edits and can change their properties by object inspector.
but tedit.create(nil), tedit.create(self) cant change edits' properties using object inspector.
any idea?
but tedit.create(nil), tedit.create(self) cant change edits' properties using object inspector.
any idea?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Did it work ?
Thanks, and regards
Thanks, and regards
fedit1.Name := 'MyEdit1';
etc...
Rob;-)