R
Robert Ludig
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?
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?