reusing treenodes in multiple treeviews...

T

Tim Mackey

this is an unusual problem and there doesn't seem to be anything about it
online.
i have several winforms that create different treeviews based on the same
data, they may be opened by the user at the same time, and i want to achieve
consistency between all views, without resorting to regenerating the entire
tree from scratch every time a value changes in a node. the data for the
treeviews is made up of two types of objects, both derived from TreeNode.

it is no problem to add the nodes to one treeview, but if i add the same
nodes to another treeview they disappear out of the original one. before i
set the data objects to inherit from TreeNode, i used to have them stored in
the Tag of regular TreeNodes but the code is quite cumbersome, and there is
no direct databinding between the objects and the treeview. i don't want to
clone the nodes because then i would also lose the direct databinding with
the data objects when they change.

any ideas would be very appreciated
tim
 
J

Justin Rogers

Create a controlling object that generates treeNodes and establishes a
relationship
between tree nodes that are peers. When one peer changes you can cross
propagate
the property to the remaining peer nodes. An example might be a simple
Hashtable
that indexes an array of TreeNode objects (the array being the peers) per tag or
other
defining key.
 

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

Top