tree tag object

  • Thread starter Thread starter bob
  • Start date Start date
B

bob

Hi.. I have a usercontrol that I'm assigning to a tag while setting up
treenodes.. I'd like to be able to get access to that userControl from
the tag on a tree double click..

tv.UserControl1 uc;
uc=new tV.UserControl1();

node.Nodes.Add("one");
node.Nodes[node.GetNodeCount(false)-1].Tag=uc;

On Double Click of a tree node I'd like to get to that UserControl I
tagged..
Anyone know if this can or how to do this? I can use gettype to see
that
the tag is my UserControl, but I can't seem to get to the UserControl
to access it's properties/functions etc... any help would be
appreciated..

Thanks , John
 
Hi John
Try this

MyUserControl MyTagObject = (MyUserControl)tv.Nodes[tv.CurrentNode].tag;

or

MyUserControl MyTagObject = tv.Nodes[tv.CurrentNode].tag as MyUserControl;

This will not throw an exception but return null in MyTagObject if the tag
is not of type MyUserControl.

Accessing of the Nodes in the tree is probably not correct above but you get
the idea :)

HTH
JB
 

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