问题
There is probably a really straightforward answer to this but I'm having difficulty finding it.
Simple, I have a TreeNode and I would like to make its visibility false. (or another way of not allowing it to be shown until required).
Edit - Another Question?
I'm confused as to how there isn't a Visible attribute but then there is the property:
Node.PrevVisibleNode;
What is the difference between this and Node.PrevNode
?
Thanks,
回答1:
I don't think you can do that. There is an IsVisible
property, but it is readonly and will indicate whether the node is currently visible within the client area of the TreeView
control. I think you will need to remove it from the nodes collection in which it resides (and optionally remember the position of it to be able to restore it.
回答2:
Hmm... I originally (and incorrectly) mentioned IsVisible
. However, on inspection I expect the answer is simply: don't add it until you need it.
This is easier if your UI model is an abstraction above your actual data model, so you can store items in the data model regardless of their visibility, and simply update the UI (add/remove/update nodes) as necessary.
回答3:
I don't think you can. You'll have to remove the node.
回答4:
Node.PrevVisibleNode;
I think this means visible as in it's visible to the user (all parent nodes are expanded)
来源:https://stackoverflow.com/questions/1199417/how-do-i-make-a-treenode-not-visible-c