how to set integer in treenode tag

hi
I need to save a counter for each tree node and I think the best place to store is in the node.tag
my question is how could I make the tag store integer number so i can increment it each time

p.s i am using tree view in c#

thanks in  advance for your help

suzan

suzan_Asked:
Who is Participating?
 
philipjonathanConnect With a Mentor Commented:
TreeNode.Tag actually accepts object data type, which means you can assign anything, including integer. The only thing to remember is that, don't assign it through the visual studio designer, because it will treat data as string.

To assign:
node.Tag = 1;

To read data:
int tagValue = (int) node.Tag;
0
 
suzan_Author Commented:
thanks a lot philipjonathan
its really help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.