• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 806
  • Last Modified:

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

0
suzan_
Asked:
suzan_
1 Solution
 
philipjonathanCommented:
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now