We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Collapsing all child nodes of a parent node in a tree view control

Thread ID:

Created:

Updated:

Platform:

Replies:

15864 Jun 29,2004 08:05 AM Jul 2,2004 01:17 PM Windows Forms 7
loading
Tags: Tools
Anil Kumar M
Asked On June 29, 2004 08:05 AM

Hi, I got a tree control where the order of nodes is three, i.e Parent node---->First child node----> n child nodes of First child node. i want to collapse all the child nodes of FirstChildNode. when i select any one of the child nodes , except the selcted node all the other child nodes should be closed. iam doing like this in treenode_select() event this.treJob.TopVisibleNode.FirstNode.CollapseAll(); this.treJob.TopVisibleNode.FirstNode.Expand(); but iam not successfull any clues.... regards seash

Administrator [Syncfusion]
Replied On June 29, 2004 12:59 PM

Hi Seash Here is a code snippet that demonstrates how when you right click on a node in a TreeViewAdv control and if it is not a top level node, it''s child nodes are collapsed: private void treeViewAdv1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if ((e.Button == MouseButtons.Right)&& (this.treeViewAdv1.SelectedNode.Level!=1)) { if ((this.treeViewAdv1.SelectedNode.HasChildren)) { this.treeViewAdv1.SelectedNode.CollapseAll(); } else { MessageBox.Show("The selected node has no child nodes"); } } } This should give you an idea to do what you are seeking. Regards Arun

Satish
Replied On June 30, 2004 12:48 AM

Hi Arun, I just spoke to Seash. I made document what Seash whats in the TreeView. Please find the document. Thanks Satish >Hi Seash > >Here is a code snippet that demonstrates how when you right click on a node in a TreeViewAdv control and if it is not a top level node, it''s child nodes are collapsed: > >private void treeViewAdv1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) >{ > if ((e.Button == MouseButtons.Right)&& (this.treeViewAdv1.SelectedNode.Level!=1)) > { > if ((this.treeViewAdv1.SelectedNode.HasChildren)) > { > this.treeViewAdv1.SelectedNode.CollapseAll(); > } > else > { > MessageBox.Show("The selected node has no child nodes"); > } > } >} > >This should give you an idea to do what you are seeking. > >Regards >Arun > TreeError_4660.zip

Satish
Replied On July 1, 2004 08:02 AM

Hi Arun, Please hightlight the solution. Thanks Satish >Hi Arun, >I just spoke to Seash. I made document what Seash whats in the TreeView. >Please find the document. >Thanks >Satish > >>Hi Seash >> >>Here is a code snippet that demonstrates how when you right click on a node in a TreeViewAdv control and if it is not a top level node, it''s child nodes are collapsed: >> >>private void treeViewAdv1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) >>{ >> if ((e.Button == MouseButtons.Right)&& (this.treeViewAdv1.SelectedNode.Level!=1)) >> { >> if ((this.treeViewAdv1.SelectedNode.HasChildren)) >> { >> this.treeViewAdv1.SelectedNode.CollapseAll(); >> } >> else >> { >> MessageBox.Show("The selected node has no child nodes"); >> } >> } >>} >> >>This should give you an idea to do what you are seeking. >> >>Regards >>Arun >> > >TreeError_4660.zip > >

Administrator [Syncfusion]
Replied On July 1, 2004 11:39 AM

Hi Satish Here you go: private void treeViewAdv1_AfterSelect(object sender, System.EventArgs e) { if ((this.treeViewAdv1.SelectedNode.Level==1)&&(this.treeViewAdv1.SelectedNode.HasChildren) &&(this.treeViewAdv1.SelectedNode.Expanded)) { this.treeViewAdv1.CollapseAll(); this.treeViewAdv1.SelectedNode.ExpandAll(); } } Regards Arun

Satish
Replied On July 1, 2004 09:30 PM

Hi Arun, The code you have mentioned below is not working. I want to achive same resuls as i posted the document in form. Thanks Satish >Hi Satish >Here you go: >private void treeViewAdv1_AfterSelect(object sender, System.EventArgs e) >{ > if ((this.treeViewAdv1.SelectedNode.Level==1)&&(this.treeViewAdv1.SelectedNode.HasChildren) > &&(this.treeViewAdv1.SelectedNode.Expanded)) > { > this.treeViewAdv1.CollapseAll(); > this.treeViewAdv1.SelectedNode.ExpandAll(); > } >} > >Regards >Arun >

Administrator [Syncfusion]
Replied On July 2, 2004 01:16 PM

Hi Satish Here is a sample that does what you are looking for. This is the relevant code from the sample: bool b = false; private void treeViewAdv1_AfterSelect(object sender, System.EventArgs e) { if ((this.treeViewAdv1.SelectedNode.Level==1)&&(this.treeViewAdv1.SelectedNode.HasChildren))//&&(this.treeViewAdv1.SelectedNode.Expanded)) { this.treeViewAdv1.CollapseAll(); this.treeViewAdv1.SelectedNode.ExpandAll(); } } private void treeViewAdv1_AfterExpand(object sender, Syncfusion.Windows.Forms.Tools.TreeViewAdvNodeEventArgs e) { if (b) { b = false; this.treeViewAdv1.CollapseAll(); e.Node.ExpandAll(); this.treeViewAdv1.SelectedNode = e.Node; } b = true; } We would really appreciate it if you could use Direct-Trac for specific issues like this in future. Regards Arun

Administrator [Syncfusion]
Replied On July 2, 2004 01:17 PM

Hi Satish Here is a link to the sample. Regards Arun

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;