BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Walking the treeview

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Greg Stantin
Guest





PostPosted: Sun Jan 25, 2004 2:50 am    Post subject: Walking the treeview Reply with quote



How do you walk the tree from the selected node to
the last child within that branch?

TTreeNode* ChildNode = TreeView1->Selected;
while(ChildNode)
{
ChildNode->Selected = true;
String ss = ChildNode->Text;
TreeView1->SetFocus();
Sleep(1000);

ChildNode->GetNextChild(ChildNode);
}

This is my layout

ParentNode1
ChildNode1
ChildNode2
ChildNode3
ChildNode4
ChildNode5
ChildNode6
ChildNode7
ChildNode8

If i select ParentNode1, it must end up on ChildNode8, if i select
ChildNode3,
the last node that will highlight will be ChildNode5.

Not sure what i am missing, but my loop is not going anywhere to get
the result.


Thanks.


Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sun Jan 25, 2004 7:46 am    Post subject: Re: Walking the treeview Reply with quote




"Greg Stantin" <gstantin (AT) stantonassoc (DOT) com> wrote


Quote:
If i select ParentNode1, it must end up on ChildNode8,
if i select ChildNode3, the last node that will highlight will
be ChildNode5.

You need to provide more details. Given the example layout you mentioned
earlier, if you click on ParentNode1, should it do anything with ChildNode1,
ChildNode2, and so on, or just jump directly to ChildNode8? What EXACTLY do
you want to do with the walking?


Gambit



Back to top
Greg Stantin
Guest





PostPosted: Sun Jan 25, 2004 4:03 pm    Post subject: Re: Walking the treeview Reply with quote



Quote:
earlier, if you click on ParentNode1, should it do anything with
ChildNode1,
ChildNode2, and so on, or just jump directly to ChildNode8? What
EXACTLY do


ParentNode1
ChildNode1
ChildNode2
ChildNode3
ChildNode4
ChildNode5
ChildNode6
ChildNode7
ChildNode8

ParentNode2
ChildNode1
ChildNode2
ChildNode3
ChildNode4
ChildNode5
ChildNode6
ChildNode7
ChildNode8

I want it to walk down each node in the following order. If i click
on ParentNode1,
it will go from ParentNode1, ChildNode1, 2, 3, 4, 5 ,6, 7, 8 and then
stop.
In the same way if i click on lets says ChildNode3, it will go to
ChildNode4, then
ChildNode5, then stop. Basically, it will go down each node of the
branch that
is attached to the Selected node.



Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sun Jan 25, 2004 10:54 pm    Post subject: Re: Walking the treeview Reply with quote

"Greg Stantin" <gstantin (AT) stantonassoc (DOT) com> wrote


Quote:
I want it to walk down each node in the following order.
If i click on ParentNode1, it will go from ParentNode1,
ChildNode1, 2, 3, 4, 5 ,6, 7, 8 and then stop.

There are two different ways to handle that:

1)
DoSomethingWithNode(TreeView1->Selected);

void __fastcall DoSomethingWithNode(TTreeNode *Node)
{
if( Node )
{
// do something with Node...

Node = Node->getFirstChild();
while( Node )
{
DoSomethingWithNode(Node);
Node = Node->getNextSibling();
}
}
}


2)
TTreeNode *Node = TreeView1->Selected;
if( Node )
{
TTreeNode *StopNode = Node->getNextSibling();
while( Node != StopNode )
{
// do something with Node ...
Node = Node->GetNext();
}
}


Gambit



Back to top
Greg Stantin
Guest





PostPosted: Sun Jan 25, 2004 11:12 pm    Post subject: Re: Walking the treeview Reply with quote

Quote:
There are two different ways to handle that:


Thanks Gambit.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.