如何使用C#在树视图控件中选择内部节点 [英] How to select inner nodes in tree view control using C#

查看:218
本文介绍了如何使用C#在树视图控件中选择内部节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行树视图控制。



我已将所有驱动器作为节点。



如果我选择一个驱动器,它应该选择所有文件夹及其子文件夹。



如何做到这一点。我使用Checkbox来选择这些驱动器

解决方案

你明白通过将驱动器名称放在TreeView中,这就是你所拥有的。您必须提供用于在驱动器节点下添加目录节点的代码。



我强烈建议你一次只下降一个级别。例如,仅在所选驱动器下方添加目录节点。如果选择了其中一个目录,则只展开节点以包含所选目录的子目录。否则用户将面临漫长的等待时间。



此外,还有一个控件可以执行您想要的操作。它被称为文件夹浏览器对话框 [< a href =http://msdn.microsoft.com/en-us/library/system.windows.forms.folderbrowserdialog(v=vs.90).aspx\"target =_ blanktitle =New Window> ^ ]。

I am having a tree view control.

I have given all drives as nodes.

If I select a drive it should select all the folders and its subfolders.

How to do this. I use Checkbox to select these drives

解决方案

You do understand that by placing the drive names in a TreeView, that's all you have. You must supply code that adds the directory nodes beneath the drive nodes.

I strongly suggest that you only descend one level at a time. For example only add directory nodes immediately beneath a selected drive. If one of those directories is selected, only expand the nodes to include the the selected directory's subdirectories. Otherwise the user will be faced with long wait times.

Also, there is a control to do what you appear to want. It's called Folder Browser Dialog[^].


这篇关于如何使用C#在树视图控件中选择内部节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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