tags:

views:

132

answers:

3

I was thinking that that this would be a useful way to display what would appear to be a Treeview with multiple top nodes.

Example: Lets say that I want to create a TreeView of geography and I want the top nodes(s) to be countries. I could do this by:

  • World
    • Mexico
    • Japan

But what the user wants is:

  • Mexico
  • Japan

It would be nice if I could build one TreeView and simply hide World as opposed to building two TreeViews.

Update==========================

The reason that I wanted to do this was that I have routines that process the TreeView recursively, for example walking the tree before an update to preserve its collapse/expand state. It would be nice to have an invisible topnode to start processing at.

+1  A: 
tyranid
But lots of TreeView processing Can be nicely handled by calling a routine recursively starting with the top node. It gets more complex if there are multiple top nodes (or more precisely a topnode with several nextnodes all with Parent=Null). It can be done, but it would be nice to have an invisible topnode
NormD
@NormD: To do that, it's one extra function (non-recursive), that takes a `TreeNodeCollection` and calls on the second function which is the recursive part. Call the first function to traverse everything, or the second function to start at a specific node. That isn't much added complexity, since a given operation on the tree will either apply to all of it, or, most likely, the single selected node.
Jon Seigel
Of course the irony of all this is the treenode list is obviously unconnected from the display list internally and the treeview does have a "fake" root node, just it isn't technically accessible ;)
tyranid
Its not "unreasonable" or "lazy" to have a hidden top node. In my example, the countries of the world do, in fact, belong to a higher level "node" called "World" but people do not want to see it. Its not like the individual treenodes are dissimilar objects.
NormD
+3  A: 

No; and if you think about it, wouldn't you expect all children to be hidden if the parent node was hidden?

What I would do is maintain the list outside of the view, and copy in items starting at a specified node.

overslacked
I can think of cases like above where I would want the children displayed even if the parent were hidden and other cases where I would not. I like options.
NormD
NormD - certainly. However, I would make the argument that what you're looking for probably isn't a TreeView. I've done a lot with owner-drawn list views, perhaps something like that is what you're after.
overslacked
A: 

There is a 3-rd party control IntegralUI TreeView which allows to have some nodes invisible, simply by setting the Visible property of the specified node. Also this control comes with advanced filter with which you can make filtering by using multiple filter values with AND, OR matching criteria.

Lokey
Well its nice to see that someone considers the capability valuable enough to build it into a product.
NormD