Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
3.50/5 (3 votes)
See more:
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
Posted
Updated 9-May-14 1:51am
v2

1 solution

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;
} 
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900