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;
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
Post a Comment