Board index » cppbuilder » Iterating in a TTreeView
|
Analian
CBuilder Developer |
Iterating in a TTreeView2005-02-18 08:55:11 PM cppbuilder95 I've got this tree view A1 B1 B2 A2 B1 B2 B3 A3 A4 int num; num = TreeView1->Items->Count; now num is 9, cause it's the total number of TreeNode s in the TreeView I want the number of immediate descendants of a TreeNode so I can iterate trough them TreeNode->Count is what I need. But I want to get a TreeNode* from the TreeNodes property of the TreeView, so I can use it's Count property. But when I do num = TreeView1->Items[0].Count; I get all the children. i.e. 9 num = TreeView1->Items[1].Count; I get 0, though I think this must be a pointer to A2 num = TreeView1->Items[2].Count; is an access violation (?) Here I don't understand if Items[int] is a TreeNode, why the code above doesn't work as I expect. When I try num = TreeView1->Items->Item->Count; I get [C++ Error] Unit1.cpp(89): E2193 Too few parameters in call to '_fastcall TTreeNodes::GetNodeFromIndex(int)' (Why?) When I try num = TreeView1->Items->Item[0]->Count; I get the number of direct children of A1. OK With num = TreeView1->Items->Item[1]->Count; I don't get the number of direct children of A2. Stupid problem but I think I'm not getting right how to use this property. I'd be grateful if someone could explain this stuff and write a short sample code. Thanks. |
