winforms - When adding a child Node to a TreeView in c# it visually looks wrong -


i'm trying add child node treeview in winforms app (using c#). problem when use following code winform looks wrong visually. here's example:

if (treeview1.nodes.count == 0)         {             treenode newguy = new treenode("new_subitem");             treeview1.nodes[0].nodes.add(newguy);             newguy.beginedit();             return;         }          treenode n = treeview1.selectednode;         treenode n3 = new treenode("new_subitem");          n.nodes.add(n3);         n3.beginedit();         return; 

here happens: inserting node treeview doing wrong?

if (treeview1.nodes.count == 0)     {         treenode newguy = new treenode("new_subitem");         treeview1.nodes[0].nodes.add(newguy);         newguy.beginedit();         return;     } 

that code senseless: first check treeview1 has no nodes(treeview1.nodes.count == 0), try access first node it's correct(treeview1.nodes[0])


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -