Board index » cppbuilder » Creating TEdits at Runtime and Controlling TEdit Names

Creating TEdits at Runtime and Controlling TEdit Names

In my application I have A TPageControl I want users to be able to add pages
to this and when they do there is
a number of associated tedit controls on each page. I want to name these so
they corespond to each page control.
I'm not sure how to do this.  Can I do something like this?

int PageCounter=3;
AnsiString A;

A = Format("TEdit%d", OPENARRAY,(TVarRec,(PageCounter)));

Then susbtitue the value of A in creating the new TEdit control something
like this

TEdit * "value of A" = new TEdit ( this );

If this will work how do I susbstitue the value of A? or is there a better
way to handle this?

 

Re:Creating TEdits at Runtime and Controlling TEdit Names


Quote
"JT" <jtol...@bullseyetelecom.com> wrote in message

news:3c21f526$1_2@dnews...

Quote
> int PageCounter=3;
> AnsiString A;

> A = Format("TEdit%d", OPENARRAY,(TVarRec,(PageCounter)));

The sprintf() method would be easier:

    A.sprintf("TEdit%d", PageCounter);

This is for BCB5, though.  If your version of Builder doesn't have the
sprintf() method, you can do this instead:

    A = ("TEdit" + IntToStr(PageCounter));

Quote
> TEdit * "value of A" = new TEdit ( this );

This is not possible.  Nor is it needed.

    TEdit *edit = new TEdit(this);
    edit->Parent = TheDesiredTabSheet;

If you need to (which most likely you won't)

    edit->Name = A;

Typically, you'd just store the pointer somewhere instead so you can refer
to the control later if you need to.  You almost never need to refer to a
dynamically-created control by name.

Gambit

Other Threads