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.

Problem in getting the node count

Thread ID:

Created:

Updated:

Platform:

Replies:

42729 Apr 5,2006 03:30 AM Apr 5,2006 05:46 AM Windows Forms 1
loading
Tags: Tools
Administrator [Syncfusion]
Asked On April 5, 2006 03:30 AM

Hi, I need to check the count of nodes. For eg if I add or remove nodes. Some confusion in total number. I tried usin getnodecount, but it didn''t help me. Thanks and regards, Rakesh

Deepa TS [Syncfusion]
Replied On April 5, 2006 05:46 AM

Hi Rakesh, You could get the total number of nodes by calling GetNodeCount method with the bool argument which indicates whether count should be including sub trees or not. If we pass it as true, it will count the nodes with the subtrees also. Code: private void button1_Click(object sender, System.EventArgs e) { // Call the tree control''s "GetNodeCount" method with true to // get the total number of nodes in the tree. int TotalNodesInTree = this.treeViewAdv1.GetNodeCount( true ); MessageBox.Show( "Total nodes in tree = " + TotalNodesInTree.ToString()); } //Add nodes private void button2_Click(object sender, System.EventArgs e) { this.treeViewAdv1.SelectedNode.Nodes.Add(new TreeNodeAdv()); } //Remove nodes private void button3_Click(object sender, System.EventArgs e) { this.treeViewAdv1.SelectedNode.Parent.Nodes.Remove(this.treeViewAdv1.SelectedNode); } I have created a sample as per your specification.Please take a look at it and let me know if this helps you. Thanks for your interest in Syncfusion products. Kind Regards, Deepa.

TotalNodes.zip

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.

;