Hi @Sudip Bhatt ,
Thank you for posting this issue in Microsoft Q&A forum.
According to your code snippets, please try to add these two code lines:
tn.Tag = element.Tag;
newTn.Tag = temp.Tag;
And the codes should be looked like this:
if (data.GetDataPresent(typeof(TreeNode)))
{
TreeNode element = (TreeNode)data.GetData(typeof(TreeNode));
TreeNode tn = new TreeNode();
tn.Text = element.Text;
tn.Name = element.Name;
tn.Tag = element.Tag;
foreach (TreeNode temp in element.Nodes)
{
TreeNode newTn = new TreeNode(temp.Text);
newTn.Tag = temp.Tag;
tn.Nodes.Add(newTn);
}
//……
}
The result:
Sincerely,
Tianyu
- If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.