Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Can someone explain to me the proper use of tags. I was thinking it was just that a reference to the node. so you can look them up or whatever. Am I missing something here?

<pre>
string[] AuthorNames = new string[bookdbDataSet.Tables[0].Rows.Count];
int row=0;
foreach (DataRow Row in bookdbDataSet.Tables[0].Rows)
{
AuthorNames[row] = Row["AuthorFirst"].ToString() + " " + Row["AuthorLast"].ToString();
TreeNode tn = new TreeNode(Row["AuthorLast"].ToString() + ',' + Row["AuthorFirst"].ToString());
tn.Tag ="2"
rootNode.Nodes.Add(tn);

row++;
}
</pre>


whenever I take and do a selectnode from the treeview for some reason the tag is always null even though I thought I was setting it to the value of 2... I that not what the tag is for ? If it is could you please explain to me what i might be doing wrong. thank you so much for all the help this board has given me.
Posted
Updated 23-Jan-10 20:01pm
v2

1 solution

See here.

As per the link, "Any Object derived type can be assigned to this property".

Try tn.Tag = Row["AuthorFirst"] to see if it works.
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900