Board index » delphi » How To Create VCL Component During Runtime

How To Create VCL Component During Runtime

Hello,

How To Create VCL Component During Runtime

Regards,

Sugeng.

 

Re:How To Create VCL Component During Runtime


Quote
Sugeng Amin wrote:
> Hello,

> How To Create VCL Component During Runtime

> Regards,

> Sugeng.

Can you be more specific?

--
Cheers,
Phillip Flores
"Keep track of your time...Use VeriTime"
http://www.pcfworks.com

Re:How To Create VCL Component During Runtime


Hi Sugeng,

You can create components in runtime by calling the class Create method.

For example, to create a TTable in a form's OnCreate method:

Table1:=TTable.Create(Self);

with Table1 do
begin
  DatabaseName:=...
  TableName:=...
  ...
  ...
  Active:=True;
end;

Note that you do not need to destroy the component as it is automatically
done by the owner of the component (which is the Form in this case) when it
is destroyed.

HTH,
Sujit

Quote
Sugeng Amin <sugeng_a...@hotmail.com> wrote in message

news:3eb9e297@newsgroups.borland.com...
Quote
> Hello,

> How To Create VCL Component During Runtime

> Regards,

> Sugeng.

Re:How To Create VCL Component During Runtime


As Sujit says, use create. He's forgotten to say that where the control is a
visible one, you also have to set its parent before it becomes visible
eg
MyEdit := TEdit.Create(Self);// create it
MyEdit.Parent := Panel1;// set parent and make it visible
MyEdit.SetBounds(100,100,MyEdit.Width,MyEdit.Height);// set position

--

Claire

Quote
"Sujit Singhania" <blackholec...@vsnl.net> wrote in message

news:3eba02c5@newsgroups.borland.com...
Quote
> Hi Sugeng,

> You can create components in runtime by calling the class Create method.

> For example, to create a TTable in a form's OnCreate method:

> Table1:=TTable.Create(Self);

> with Table1 do
> begin
>   DatabaseName:=...
>   TableName:=...
>   ...
>   ...
>   Active:=True;
> end;

> Note that you do not need to destroy the component as it is automatically
> done by the owner of the component (which is the Form in this case) when
it
> is destroyed.

> HTH,
> Sujit

> Sugeng Amin <sugeng_a...@hotmail.com> wrote in message
> news:3eb9e297@newsgroups.borland.com...
> > Hello,

> > How To Create VCL Component During Runtime

> > Regards,

> > Sugeng.

Other Threads