Microsoft教程创建包含ListView和TreeView控件的表单。 [英] Microsoft Tutorial To create the form containing a ListView and TreeView control.
问题描述
Private Sub PopulateTreeView()
Dim rootNode As TreeNode
Dim info As New DirectoryInfo("..\..")
If info.Exists Then
rootNode = New TreeNode(info.Name)
rootNode.Tag = info
GetDirectories(info.GetDirectories(), rootNode)
TreeView1.Nodes.Add(rootNode)
End If
End Sub
上面的代码来自教程,我的工作正常。
The above code comes from the tutorial, and I have it working fine.
但是我想更改一行:
However I would like to change the line:
Dim info As New DirectoryInfo("..\..")
要在树视图中显示完整的C驱动器,而不是部分选择,这会让我感觉到。
To show from the complete C drive in treeview, not the partial selection this gets me.
感谢您的帮助。
推荐答案
您好
构建文件资源管理器类型项目有很多例子 - Google'vb.net文件资源管理器示例'为某些t下降。
There are many many examples for building an File Explorer type project around - Google 'vb.net File Explorer example' for some of them.
通常,整个驱动器包含数千个文件,因此,最佳做法是对其进行组织,以便只有当用户打开文件夹的树节点时才会获取文件夹的文件。夹。否则,响应能力会受到严重影响。
考虑的其他事情是使用(比方说)BackGroundWorker来处理向TreeView提取/添加文件以保持UI响应。
Usually, a whole drive contains thousands of files and so, it is best practice to organize it so that the files for a folder are only fetched when user opens the Tree Node of the folder. Otherwise, responsiveness can be severely affected. Other things to consider is to use (say) a BackGroundWorker to deal with the fetching/adding files to the TreeView to keep the UI responsive.
这篇关于Microsoft教程创建包含ListView和TreeView控件的表单。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!