)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to customize WinForms MultiCoulumnTreeView like FileExplorer?

Platform: WinForms |
Control: MultiColumnTreeView |
Published Date: January 29, 2015 |
Last Revised Date: January 7, 2020

Customize the MultiColumnTreeView

In MultiColumnTreeView, you can load the files as you load in File Explorer, by using DriveInfo, DirectoryInfo class and by handling NodeMouseDoubleClick event. The following code example is used to get the files from directories.

C#

//To get directory
DriveInfo drive = new DriveInfo(e.Node.Text);
DirectoryInfo dir = drive.RootDirectory;
//To get all files
foreach (FileInfo fi in dir.GetFiles())
{
    TreeNodeAdv item = new TreeNodeAdv(fi.Name);
    item.ShowPlusMinus = false;
    e.Node.Nodes.Add(item);
}
//To open selected files
void multiColumnTreeView1_NodeMouseDoubleClick(object sender, MultiColumnTreeViewAdvMouseClickEventArgs e)
{
    if (e.Node.Text.Contains("."))
        System.Diagnostics.Process.Start(e.Node.FullPath);
}

VB

'To get directory
Dim drive As New DriveInfo(e.Node.Text)
dir = drive.RootDirectory
'To get files
For Each fi As FileInfo In dir.GetFiles()
    Dim item As New TreeNodeAdv(fi.Name)
    item.ShowPlusMinus = False
    e.Node.Nodes.Add(item)
Next fi
'To open selected files
Private Sub multiColumnTreeView1_NodeMouseDoubleClick(ByVal sender As Object, ByVal e As MultiColumnTreeViewAdvMouseClickEventArgs)
    If e.Node.Text.Contains(".") Then
       System.Diagnostics.Process.Start(e.Node.FullPath)
    End If
End Sub

The following screenshot illustrates the output.

Files loaded as loaded in File explorer

Figure 1: Files loaded as loaded in File Explorer

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/MultiColumnTreeView_Folderbrowser1165728106.zip

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon