如何使 TreeNode 不可见? (C#)

发布于 2024-07-29 05:07:18 字数 259 浏览 8 评论 0原文

对此可能有一个非常简单的答案,但我很难找到它。

很简单,我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

巴黎盛开的樱花 2024-08-05 05:07:18

我认为你做不到。 有一个 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 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.

物价感观 2024-08-05 05:07:18

嗯...我最初(错误地)提到了 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.

霓裳挽歌倾城醉 2024-08-05 05:07:18

我认为你不能。 您必须删除该节点。

I don't think you can. You'll have to remove the node.

走过海棠暮 2024-08-05 05:07:18

Node.PrevVisibleNode;

我认为这意味着可见,因为它对用户可见(所有父节点都已展开)

Node.PrevVisibleNode;

I think this means visible as in it's visible to the user (all parent nodes are expanded)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文