如何使 TreeNode 不可见? (C#)
对此可能有一个非常简单的答案,但我很难找到它。
很简单,我有一个 TreeNode,我想让它的可见性为 false。 (或者在需要之前不允许显示的另一种方式)。
编辑 - 另一个问题?
我很困惑为什么没有 Visible 属性,但有属性:
Node.PrevVisibleNode;
这和 Node.PrevNode 之间有什么区别?
谢谢,
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,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为你做不到。 有一个
IsVisible
属性,但它是只读的,将指示该节点当前在TreeView
控件的工作区中是否可见。 我认为您需要将其从它所在的节点集合中删除(并且可以选择记住它的位置以便能够恢复它。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 theTreeView
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.嗯...我最初(错误地)提到了
IsVisible
。 然而,经过检查,我希望答案很简单:在需要之前不要添加它。如果您的 UI 模型是实际数据模型之上的抽象,那么这会更容易,因此您可以将项目存储在数据模型中,而不管其可见性如何,并且只需更新 UI(根据需要添加/删除/更新节点)。
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.
我认为你不能。 您必须删除该节点。
I don't think you can. You'll have to remove the node.
我认为这意味着可见,因为它对用户可见(所有父节点都已展开)
I think this means visible as in it's visible to the user (all parent nodes are expanded)