如何在C#中的Combobox中添加文件夹浏览器? [英] How Can I Add Folder Browser Inside A Combobox In C# ?

查看:77
本文介绍了如何在C#中的Combobox中添加文件夹浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我如何在c#中的组合框中添加文件夹浏览器?在组合框中使用可以从我的电脑中选择任何文件夹吗?他会看到组合框内的所有驱动器和文件夹。





dropdownfolderbrowser

Hi all how can i add a folder browser in a combobox in c# ? in combobox use can select any folder from my computer ? he will see all the drives and folder inside that combobox.


dropdownfolderbrowser

推荐答案

该下拉列表正在打开treview节点文件。首先,你必须制作一个treeview组合框。

然后你将绑定系统目录列表。

我们提供一些部分解决方案,让你在你身边找到一个好的解决方案

带树视图的第一个组合框

http:// www。 brad-smith.info/blog/archives/193 [ ^ ]

http:/ /demos.telerik.com/aspnet-ajax/treeview/examples/functionality/treeviewcombobox/defaultcs.aspx [ ^ ]





获取要在此组合框上绑定的系统目录

That dropdown is opening a treview node file. For this first you have to make one treeview combobox.
Then you will bind system direcotory list.
We are providing some part solution to make you a good solution from your side
First combobox with treeview
http://www.brad-smith.info/blog/archives/193[^]
http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/treeviewcombobox/defaultcs.aspx[^]


Get the system directory to bind on this combobox
void ListDirectory()
{
    treeView1.Nodes.Clear();
    var rootDirectoryInfo = new DirectoryInfo(txtPath.Text);
    treeView1.Nodes.Add(CreateDirectoryNode(rootDirectoryInfo));
    LoadFileDetails("");
}
TreeNode CreateDirectoryNode(DirectoryInfo directoryInfo)
{
    var directoryNode = new TreeNode(directoryInfo.Name);
    try
    {
        foreach (var directory in directoryInfo.GetDirectories())
        {
            directoryNode.Nodes.Add(CreateDirectoryNode(directory)); 
        } 
    }
    catch (UnauthorizedAccessException) { }
    catch (Exception) { }
    return directoryNode;
} 


这篇关于如何在C#中的Combobox中添加文件夹浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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