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('Samples', [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.
eYesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RBertoraCommented:
Have you tried:
fedit1.Name := 'MyEdit1';
etc...
Rob;-)
0
eYesAuthor Commented:
"auto" ?
0
LischkeCommented:
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
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

eYesAuthor Commented:
could u give me some samples?
0
KECommented:
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
0
LischkeCommented:
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
0
eYesAuthor Commented:
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.
0
KECommented:
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

0
eYesAuthor Commented:
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?
0
KECommented:
Yes !

Override the getChildren method of  TNoUsage.
In the getChildren method you should not return/report you TEdit's. This way they are not saved automatically to the stream, and also they are not automatically created for you when you load the form again into the designer.

But - as you probably wan't to make the edit's persistent you will have to save them manually. So you will also need to override the defineproperties method (TNoUsage) and define a property where your controls can be stored. Then you have to write two methods (still TNoUsage) for save and load of the TEdit's, where you just use ReadComponent and WriteComponent on each of your already created TEdit's.

Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KECommented:
Did it work ?

Thanks, and regards
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.