Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
When i use the following code in c# it gives error
parent.ChildNodes.Add(child);
nParent.PopulateOnDemand = true;


Error 15 'System.Windows.Forms.TreeNode' does not contain a definition for 'ChildNodes' and no extension method 'ChildNodes' accepting a first argument of type 'System.Windows.Forms.TreeNode' could be found (are you missing a using directive or an assembly reference?)

Error 3 'System.Windows.Forms.TreeNode' does not contain a definition for 'PopulateOnDemand' and no extension method 'PopulateOnDemand' accepting a first argument of type 'System.Windows.Forms.TreeNode' could be found (are you missing a using directive or an assembly reference?)

Help Me.............
Posted
Updated 9-Aug-13 6:04am
v2

Try:
C#
parent.Nodes.Add(child);
 
Share this answer
 
Comments
Manas Bhardwaj 9-Aug-13 12:04pm    
You beat me. +5!
OriginalGriff 9-Aug-13 12:09pm    
Nah - I just typed faster! :laugh:
NoorKaximi 9-Aug-13 12:16pm    
What is the solution for error in 2nd code?
OriginalGriff 9-Aug-13 12:21pm    
There isn't one - PopulateOnDemand is a System.Web.UI.TreeNode property, not a System.Windows.Forms.TreeNode property. If you are using Winforms, you don't have the property. If you are doing a website, why have you got Winforms controls in there?
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treenode.populateondemand.aspx
NoorKaximi 9-Aug-13 12:24pm    
i m working on database software not on any website.....
According to MSDN, the property is called Nodes [^]and not ClildNodes

http://msdn.microsoft.com/en-us/library/system.windows.forms.treenode.aspx[^]
 
Share this answer
 
Comments
NoorKaximi 9-Aug-13 12:13pm    
What is the solution for 2nd code error?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900