tags:

views:

25

answers:

2

Hi

Is it possible to save two objects in the tag property of a treeview node?

If so, how can I do so

Thanks bornagaindeveloper

+2  A: 

No, but it is possible to write a third class which has two properties pointing to your classes and save this third object to the treenode tag. You could also use the Tuple class that has been introduced in .NET 4.0 if you don't want to write a third class yourself but I must admit that it could make your code more readable if you did.

Darin Dimitrov
that would mean creating the third class with two properties (one for each of the objects), instantiating the class, and saving the object.right?
bornagaindeveloper
@bornagaindeveloper, yes exactly.
Darin Dimitrov
I know it has been a long time..but this answer was very useful
bornagaindeveloper
+1  A: 

You could store the values to array and store array in Tag.

node.Tag = new object[] {value1, value2};
value1_ = ((object[])node.Tag)[0];
...
olegz