Board index » cppbuilder » How to create a TTreeView dynamically?

How to create a TTreeView dynamically?


2003-08-27 05:05:02 PM
cppbuilder62
Dear all,
Here is part of my codes.
----------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
TTreeView *TV=new TTreeView(Application);
TV->Width=200;
TV->Height=100;
TV->Top=0;
TV->Left=0;
// TV->Color=clGreen;
// TV->Items->AddChild(NULL,"test");
TV->Visible=true;
}
----------------------------------------------------------------------
When I press run, I can't see a TreeView in this form.
if I add TV->Color=clGreen; or TV->Items->AddChild(NULL,"test");,
I'll appear a exception, class EInvalidOperation with message Control "has
no parent window".
How to solve it? or How to create a TreeView correctly?
Thanks for your answer.
Regards,
cylin.
 
 

Re:How to create a TTreeView dynamically?

don't forget the Parent of the tree needs setting - this is the 'Window'
it's inside and would normally be:
TTreeView *TV=new TTreeView(Application);
TV->Parent = this; // where 'this' is the Current form
HTH Pete
"cylin" < XXXX@XXXXX.COM >wrote in message
Dear all,
Here is part of my codes.
----------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
TTreeView *TV=new TTreeView(Application);
TV->Width=200;
TV->Height=100;
TV->Top=0;
TV->Left=0;
// TV->Color=clGreen;
// TV->Items->AddChild(NULL,"test");
TV->Visible=true;
}
----------------------------------------------------------------------
When I press run, I can't see a TreeView in this form.
if I add TV->Color=clGreen; or TV->Items->AddChild(NULL,"test");,
I'll appear a exception, class EInvalidOperation with message Control "has
no parent window".
How to solve it? or How to create a TreeView correctly?
Thanks for your answer.
Regards,
cylin.
 

Re:How to create a TTreeView dynamically?

There is an example in this Web page
www.geocities.com/rodolfofrino/TreeViewWithColouredNodes.html
Rodolfo
"cylin" < XXXX@XXXXX.COM >wrote in message
Quote
Dear all,

Here is part of my codes.
----------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
TTreeView *TV=new TTreeView(Application);
TV->Width=200;
TV->Height=100;
TV->Top=0;
TV->Left=0;
// TV->Color=clGreen;
// TV->Items->AddChild(NULL,"test");

TV->Visible=true;
}
----------------------------------------------------------------------
When I press run, I can't see a TreeView in this form.
if I add TV->Color=clGreen; or TV->Items->AddChild(NULL,"test");,
I'll appear a exception, class EInvalidOperation with message Control "has
no parent window".
How to solve it? or How to create a TreeView correctly?
Thanks for your answer.

Regards,
cylin.


 

{smallsort}

Re:How to create a TTreeView dynamically?

Thanks all.
I got it.
Regards,
cylin.
"cylin" < XXXX@XXXXX.COM >glsD
:bihs7s$9goji$ XXXX@XXXXX.COM ...
Quote
Dear all,

Here is part of my codes.
----------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
TTreeView *TV=new TTreeView(Application);
TV->Width=200;
TV->Height=100;
TV->Top=0;
TV->Left=0;
// TV->Color=clGreen;
// TV->Items->AddChild(NULL,"test");

TV->Visible=true;
}
----------------------------------------------------------------------
When I press run, I can't see a TreeView in this form.
if I add TV->Color=clGreen; or TV->Items->AddChild(NULL,"test");,
I'll appear a exception, class EInvalidOperation with message Control "has
no parent window".
How to solve it? or How to create a TreeView correctly?
Thanks for your answer.

Regards,
cylin.