在C#空扩展树节点 [英] Empty expandable treenode in C#

查看:152
本文介绍了在C#空扩展树节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建立在C#中一个可扩展的空树节点,即一个TreeNode是空的,有它旁边的[+]号。究其原因是因为最初它是空的,但一旦一个节点被点击,我想有许多子节点来填充它。

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?

推荐答案

您必须重新绘制树本身,或创建当父节点展开一个空节点,并直接将其移除。

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

就个人而言,我会去的选项b)。我以前做过这个,前一阵子,并感谢由树视图它很容易做到引发的事件。
你可以给空节点像一个值正在载入所以它提供了一些反馈给用户也是如此。 :)

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. :)

这篇关于在C#空扩展树节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆