C# 中的空可扩展树节点

发布于 2024-12-17 15:36:50 字数 143 浏览 2 评论 0原文

我想在 C# 中创建一个可扩展的空树节点,即一个空的树节点,旁边有 [+] 符号。原因是因为最初它是空的,但是一旦单击一个节点,我想用许多子节点填充它。

我面临的唯一问题是空树节点不可扩展,所以我不知道该怎么办。有没有办法解决这个问题,或者有什么解决方法?

I want to create an expandable empty treenode in C#, i.e. a treenode which is empty and has the [+] sign beside it. The reason is because initially it is empty, but once a node is clicked, I want to populate it with many child nodes.

The only problem I am facing is that empty treenodes aren't expandable, so I don't know what to do. Is there a way to solve this problem, or are there any workarounds?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

掌心的温暖 2024-12-24 15:36:50

您必须重新绘制树本身,或者创建一个空节点,然后在展开父节点时将其删除。

就我个人而言,我会选择 b) 选项。我以前做过这个,不久前,由于 TreeView 引发的事件,它很容易完成。
您可以为空节点指定一个值,例如“正在加载...”,这样它也会向用户提供一些反馈。 :)

You have to redraw the tree itself, or create an empty node and simply remove it when the parent node is expanded.

Personally, I'd go for option b). I've done this before, a while ago and thanks to the events raised by the TreeView it pretty easy to accomplish.
You can give the empty node a value like 'Loading...' so it gives some feedback to the user as well. :)

明明#如月 2024-12-24 15:36:50

添加一个虚拟子节点,并在展开时将其删除。

Add a dummy child node, and remove it when you expand.

老旧海报 2024-12-24 15:36:50

看看 Josh Smith 关于树视图的优秀教程。它允许通过在扩展时删除虚拟节点来延迟加载子树节点。

Have a look at Josh Smiths excellent tutorial on treeviews. It allows lazy loading of child tree nodes by having a dummy node that is removed upon expansion.

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