Getting back objects from treenode.tag

  • Thread starter Thread starter tiger79
  • Start date Start date
T

tiger79

Hi,
I've made a Treeview which obviously contains treeNodes. Because of the fact
I wanted to place more info in every treeNode I made a struct which contains
2 variables. A integer one (ID) and a boolean one. I have no problem at all
assigning the coorect values and placing this object in the nodes tag. My
problem is retrieving the information stored :( How is this done ??? I have
made a method GetID in my struct but I can't seem to call it, and honestly I
wouldn't even know how to call it...
I can place some code if it's needed...
 
Since the Tag property returns an Object you won't see your custom method on
it, however you can cast this to your known type to access the custom
fields/methods etc e.g.

[C#]
CustomStruct cs = (CustomStruct)Node.Tag;
int myid = cs.GetID();

Peter
 
Thanx,
it works now :D
I love this newsgroup !!! and u guys as well :)


Peter Foot said:
Since the Tag property returns an Object you won't see your custom method on
it, however you can cast this to your known type to access the custom
fields/methods etc e.g.

[C#]
CustomStruct cs = (CustomStruct)Node.Tag;
int myid = cs.GetID();

Peter

--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org

tiger79 said:
Hi,
I've made a Treeview which obviously contains treeNodes. Because of the
fact
I wanted to place more info in every treeNode I made a struct which
contains
2 variables. A integer one (ID) and a boolean one. I have no problem at
all
assigning the coorect values and placing this object in the nodes tag. My
problem is retrieving the information stored :( How is this done ??? I
have
made a method GetID in my struct but I can't seem to call it, and honestly
I
wouldn't even know how to call it...
I can place some code if it's needed...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top