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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Problem in getting the node count

Thread ID:





42729 Apr 5,2006 07:30 AM UTC Apr 5,2006 09:46 AM UTC WinForms 1
Tags: Tools
Administrator [Syncfusion]
Asked On April 5, 2006 07:30 AM UTC

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 09:46 AM UTC

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.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon