I have created a treeview in my project but problem while cliking on nodes then all nodes coming to show again to below of tree.
Loading
I have created a treeview in my project but problem while cliking on nodes then all nodes coming to show again to below of tree.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Srinivasan RamamoorthiPosted Oct 29, 2021, 1:51 PM
You have to call populate treeview outside of if else condition and inside for loop.
Refer below code
private void PopulateTreeView(int parentId, TreeNode parentNode)
{
TreeNode childNode;
foreach (DataRow dr in _acountsTb.Select("[parent]=" + parentId))
{
TreeNode t = new TreeNode();
t.Text = dr["code"].ToString() + " - " + dr["ac_name"].ToString();
t.Name = dr["code"].ToString();
t.Tag = _acountsTb.Rows.IndexOf(dr);
if (parentNode == null)
{
treeView1.Nodes.Add(t);
childNode = t;
}
else
{
parentNode.Nodes.Add(t);
childNode = t;
}
PopulateTreeView(Convert.ToInt32(dr["code"].ToString()), childNode);
}
}
sanjeev royPosted Oct 29, 2021, 5:50 PM
sanjeev royPosted Oct 29, 2021, 1:25 PM
Srinivasan RamamoorthiPosted Oct 29, 2021, 1:19 PM
sanjeev royPosted Oct 29, 2021, 1:11 PM
Ramamoorthi, I had check with this code but not solved even i had tried by some other , still showing same .
Srinivasan RamamoorthiPosted Oct 29, 2021, 10:43 AM
Vikas PanwarPosted Oct 29, 2021, 8:52 AM
Vikas PanwarPosted Oct 29, 2021, 8:52 AM