Board index » cppbuilder » TreeView vs Index problem

TreeView vs Index problem


2005-03-27 08:27:15 AM
cppbuilder22
Please help.
This is working well:
Form1->ListBox1->Items->Objects[nIndex]=(TObject*)props.dwFolderId;
I need applicate it to TreeView. Like this:
Form1->TreeView1->Items->Objects[nIndex]=(TObject*)props.dwFolderId;
But its does not work.
What is the problem?
Stan
 
 

Re:TreeView vs Index problem

"Standus" < XXXX@XXXXX.COM >wrote in message
Quote
Please help.

This is working well:
Form1->ListBox1->Items->Objects[nIndex]=(TObject*)props.dwFolderId;

I need applicate it to TreeView. Like this:
Form1->TreeView1->Items->Objects[nIndex]=(TObject*)props.dwFolderId;
But its does not work.

What is the problem?
Stan
The Items[] property of a TListBox is an instance of the TStrings class
(which has an Objects[] property). The Items[] property of a TTreeView is
an instance of the TTreeNodes class (which does not have an Objects[]
property).
With a TTreeView, you have to do something more like this:
Form1->TreeView1->Items->Item[nIndex]->Data=(TObject*)props.dwFolderId;
- Dennis
 

Re:TreeView vs Index problem

Please direct your browser at info.borland.com/newsgroups/ and
read the newsgroup descriptions and guidelines. This will help you
find the appropriate newsgroup for your question.
Your question is about using a VCL component, while this newsgroup is
about the C++ programming language.
 

{smallsort}

Re:TreeView vs Index problem

"Dennis Jones" < XXXX@XXXXX.COM >wrote in message
Quote
Form1->TreeView1->Items->Item[nIndex]->Data=(TObject*)props.dwFolderId;
Minor change:
Form1->TreeView1->Items->Item[nIndex]->Data = (void*) props.dwFolderId;
Gambit
 

Re:TreeView vs Index problem

Witch this function:
Form1->TreeView1->Items->Item[nIndex]->Data=(TObject*)props.dwFolderId;
I want to assign different indexes. Like ( 568,25,496,2,586, etc...)
But if I want to get back that Index with this:
dwSelFolder = TreeView1->Selected->Index;
I got normal (different) Indexes..... like (0.1.2.3.4.5 .....)
What is the problem?
Thank you for help.
Stan.
"Thomas Maeder [TeamB]" < XXXX@XXXXX.COM >píse v diskusním príspevku
Quote

Please direct your browser at info.borland.com/newsgroups/ and
read the newsgroup descriptions and guidelines. This will help you
find the appropriate newsgroup for your question.

Your question is about using a VCL component, while this newsgroup is
about the C++ programming language.
 

Re:TreeView vs Index problem

I have a reason myself like this
To assign specific Index :
Form1->TreeView1->Items->Item[nIndex]->SelectedIndex = props.dwFolderId;
and get back this index:
dwSelFolder = TreeView1->Selected->SelectedIndex;
Stan
"Standus" < XXXX@XXXXX.COM >píše v diskusním příspěvku
Quote
Witch this function:
Form1->TreeView1->Items->Item[nIndex]->Data=(TObject*)props.dwFolderId;
I want to assign different indexes. Like ( 568,25,496,2,586, etc...)


But if I want to get back that Index with this:
dwSelFolder = TreeView1->Selected->Index;

I got normal (different) Indexes..... like (0.1.2.3.4.5 .....)

What is the problem?
Thank you for help.
Stan.


"Thomas Maeder [TeamB]" < XXXX@XXXXX.COM >píse v diskusním príspevku
news: XXXX@XXXXX.COM ...
>
>Please direct your browser at info.borland.com/newsgroups/ and
>read the newsgroup descriptions and guidelines. This will help you
>find the appropriate newsgroup for your question.
>
>Your question is about using a VCL component, while this newsgroup is
>about the C++ programming language.


 

Re:TreeView vs Index problem

"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Dennis Jones" < XXXX@XXXXX.COM >wrote in message
news:42460842$ XXXX@XXXXX.COM ...

>Form1->TreeView1->Items->Item[nIndex]->Data=(TObject*)props.dwFolderId;

Minor change:

Form1->TreeView1->Items->Item[nIndex]->Data = (void*)
props.dwFolderId;

Like I said, untested! :-) Thanks Remy!
- Dennis
 

Re:TreeView vs Index problem

"Standus" < XXXX@XXXXX.COM >wrote in message
Quote
But if I want to get back that Index with this:
dwSelFolder = TreeView1->Selected->Index;

I got normal (different) Indexes..... like (0.1.2.3.4.5 .....)
Of course you would, because you are not accessing your stored values at
all. You are accessing the Node's Index within the TreeView. Not the
integers that you stored manually. To get those, you have to access the
Data property again, ie:
TreeView1->Items->Item[nIndex]->Data = (void*) props.dwFolderId;
//...
dwSelFolder = (DWORD) TreeView1->Selected->Data;
Gambit