Click to See Complete Forum and Search --> : How to access the object associated with tree nodes tag property?


Sachinkalse
August 11th, 2004, 05:15 AM
Hi :wave:
I have different user controls associated with the tree nodes using 'tag' property, I want to display the user controls in the empty area in the form that contains the tree view control. Can any one please guide me how to access the user control using the tag property in the AfterSelect event of the tree view control?

womalley
August 16th, 2004, 07:38 AM
Just want to make sure I understand
You want to be able to identify the node that was clicked
then based on that node's tag take an action?

Sachinkalse
August 18th, 2004, 07:43 PM
thanks for the reply,
i am sorry for not putting my question in proper words, what i wanted to do was,
to get controls back that you've bound to the tag property of a TreeNode.
i found the solution, its not very difficult. pasting the same for the community.

private void myTreeView_AfterSelect(object sender, TreeViewEventArgs e)
{
if(e.Node != null)
{
UserControl uc = (UserControl) e.Node.Tag;
uc.Visible = true;
uc.BringToFront();
uc.Location = new Point(225, 240);

}
}


regards :)