If you are working on a commercial project then you might want to take
a look at Infralution's Virtual Tree control. It has a very flexible
databinding mechanism that solves many of the issues you discuss. It
implements virtual (on-demand) loading of data from the ground up which
means that it loads extremely quickly even with huge data sets and
doesn't consume large amounts of memory. Implementing this sort of
stuff is quite complex and very time consuming. You'll save the
purchase cost in a couple of hours. You can get more information and
download an evaluation from
www.infralution.com/virtualtree.html
Regards
Grant Frisken
Infralution
Robert Ludig wrote:
> I have a TreeView that displays a very big amount of complex
> hierarchical data where the elements in the tree represent all sorts of
> different datatypes. These datatyps again store one or more typed lists
> of other datatypes wich will appear as childitems in the treeview. E.g.
> the datatype "Building" has childcollections such as "Flats" or
> "Inhabitants", the datatype "Flat" again has child collections such as
> "Rooms" ... you get the idea. Each element has a unique name and each
> datatype has a unique icon.
>
> What is the best practise to implement such thing so that adding,
> (re)moving, finding, changing elements (both by using the UI or some
> internal logic that operates on the data) is fast and the code is easy
> to maintain. Should I introduce speacial treelistviewitem derived types
> for each "datatype" or should I use treelistviewitem directly and just
> attach the datatype instance as the treelistviewitem.tag ? Should each
> treelistviewitem contain the logic to update its childitems in the
> treeview or should an extrernal method read the whole data and build
> the treeview out of that? How can I identify a item in a fast way (i.e.
> without having to iterate through the whole tree)? Should I use
> Databinding ? If I introduce new datatypes at a later time I would want
> to have to touch/adjust too much code.
>
> I would be thankful for a simple example that shows off best practices
> in this regard. Or maybe there is a book on Windows Forms that has this?