c# - Checking if root nodes and child nodes in a TreeView are the same -


so have treeview , checking duplicates. if add node tree , try add same node, code won't let happen. want. need check child nodes, if root nodes same if first child of root node different 1 being added, want add child nodes under root node that's there. have tried:

if(node.text == root.text && node.firstnode.text == root.firstnode.text)        nodes.remove(node);  

but gives me null exception on root.firstnode.text , i'm not sure why getting null when node.firstnode.text shows child node.

any suggestions appreciated.

it means whatever node you've assigned root has no children (hence root.firstnode null). node.firstnode can still show it's first child node if whichever node assigned 1 different 1 assigned root.

the important thing here because have same text, doesn't mean same node. judging code provided, referring different object (with different collections of child nodes, or lack of)

i'm imagining following (not actual code):

|- somenode           //refers "root" in code. note lack of child |- somenode           //refers "node". note same text "root"   |- childnode        //would refer node.firstchild   

so you'll nodes same text, totally different layouts.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -