Frist Tree View Like this:-
+fname
mahen
manish
+lname
singh
rajpurohit
Node Name : Input Selected Node name :- singh(TextBox1)
New Node Name : Input New Node name :- barwa(TextBox2)
Click on Button1 and the result is like this
After Click Structure is like this
+fname
mahen
manish
+lname
+singhbarwa
rajpurohit
Code:--
protected void Button1_Click(object sender, EventArgs e)
{
AddChild();
final_rtn = false;
}
public bool AddChild(string cknode, string value)
{
for (int i = 0; i < TreeView1.Nodes.Count; i++)
{
if (Retun_index( TreeView1.Nodes[i], cknode, value)){return true;
}
}
return false;
}
public bool Retun_index(TreeNode tr, string cknode, string value)
{
if (tr.ChildNodes.Count > 0)
{
for (int i = 0; i < tr.ChildNodes.Count; i++)
{
TreeNode tn1 = tr.ChildNodes[i];
if ( tn1.Text == cknode)
{
TreeNode NewNode = new TreeNode();
NewNode.Text = value;tn1.ChildNodes.Add(NewNode);
final_rtn = true;goto End;
}
bool a = Retun_index(tn1, cknode, value);
}
}
else
{
return false;
}
End: ;
if (final_rtn)
{
return true;
}
else
{
return false;
}
}
Monday, December 15, 2008
Subscribe to:
Post Comments (Atom)


No comments:
Post a Comment