Explore RRS feed

All replies

  • A Treeview control has the ability to add nodes and subnodes to nodes with the nodes being expandable to display subnodes and subnodes expandable to display their subnodes.

    See Treeview Class and these search results for Treeview in this Forum.

    Below, top image is Treeview with all nodes and subnodes expanded.

    La vida loca

    Thursday, July 13, 2017 4:42 PM
  • Hi,

    use a TreeView like John said. Use its BeforeExpand and AfterExpand events for the nodes to populate the next stage if you have a complex tree to build.

    There once was an example named Create an ExplorerStyleApplication in the 101 samples, I hope its still there:

    There's a class named DirectoryTreeView (AFAIR) which shows how to do that.

    Edit: See also

    to browse the code online

    #################### Begin OT:

    @ John:

    this is what I understand by Tree-View:

    [Original Image by: I. Plenz, released under a cc licence, see

    for details]

    ################### End OT



    Thursday, July 13, 2017 6:16 PM
  • Hi Team,

    How can I create Explore like attached in




    I assume you mean the file system when you say "Explore", right?

    I don't know that this will work with the new operating systems but hopefully it will. Have you ever noticed that Windows Explorer seems to be incredibly fast at knowing what's in there?

    Part of the reason that it seems like that is because it doesn't know - it's populated dynamically. You've probably seen this: You see a subdirectory name with a "+" beside it, you click it, and the only thing that happens is that the glyph goes away.

    That's how this one works so give it a go and let me know how it works please?

    I have it set up with just one button and a TreeView control:


    Option Strict On Option Explicit On Option Infer Off Imports System.Windows.Forms Imports System.IO Public Class Form1 Private _previousDirectoryPath As String Private Sub _ Form1_Load(sender As System.Object, _ e As System.EventArgs) _ Handles MyBase.Load TreeView1.Enabled = False End Sub Private Sub _ btn_SelectDirectory_Click(sender As System.Object, _ e As System.EventArgs) _ Handles btn_SelectDirectory.Click With btn_SelectDirectory .Enabled = False .Refresh() End With Using fbd As New FolderBrowserDialog With fbd .Description = "Select The Directory" If Not String.IsNullOrWhiteSpace(_previousDirectoryPath) Then Dim di As New DirectoryInfo(_previousDirectoryPath) If di.Exists Then .SelectedPath = di.FullName Else .RootFolder = Environment.SpecialFolder.MyComputer End If End If End With If fbd.ShowDialog = Windows.Forms.DialogResult.OK Then AddRoot(fbd.SelectedPath) End If End Using End Sub Private Sub AddRoot(ByVal directoryName As String) With TreeView1 .Nodes.Clear() .Enabled = False End With If Not String.IsNullOrWhiteSpace(directoryName) Then With TreeView1.Nodes .Add(directoryName) With TreeView1.Nodes(0) .Nodes.Add("dummy") End With End With End If If TreeView1.Nodes.Count > 0 Then TreeView1.Enabled = True End If End Sub Private Sub _ TreeView1_BeforeExpand(sender As Object, _ e As System.Windows.Forms.TreeViewCancelEventArgs) _ Handles TreeView1.BeforeExpand Dim nQry As System.Collections.Generic.IEnumerable(Of TreeNode) = _ From tn As TreeNode In e.Node.Nodes.Cast(Of TreeNode)() _ Where tn.Text = "dummy" For Each tn As TreeNode In nQry e.Node.Nodes.Remove(tn) Next Dim subs() As String = GetSubdirectoryNames(e.Node.FullPath) If subs IsNot Nothing Then For Each subDirName As String In subs e.Node.Nodes.Add(subDirName) Dim lastNode As TreeNode = e.Node.Nodes(e.Node.Nodes.Count - 1) lastNode.Nodes.Add("dummy") Next End If End Sub Private Function _ GetSubdirectoryNames(ByVal mainDirectoryPath As String) As String() Dim retVal() As String = Nothing If Not String.IsNullOrWhiteSpace(mainDirectoryPath) Then Dim di As New DirectoryInfo(mainDirectoryPath) If di.Exists Then Dim infos As FileSystemInfo() = di.GetFileSystemInfos("*") If infos IsNot Nothing Then Dim tempList As New List(Of String) Dim subDirs As System.Collections.Generic.IEnumerable(Of FileSystemInfo) = _ From fsi As FileSystemInfo In infos _ Where TypeOf fsi Is DirectoryInfo AndAlso _ fsi.Attributes = 16 For Each sdi As DirectoryInfo In subDirs tempList.Add(sdi.Name) Next If tempList.Count > 0 Then retVal = tempList.ToArray End If End If End If End If Return retVal End Function End Class

    There's nothing beyond this last subdirectory so when I click on it:

    I hope it helps and I'd appreciate if you'd try it and let me know how it works on your end.

    "A problem well stated is a problem half solved.” - Charles F. Kettering

    Thursday, July 13, 2017 8:48 PM
  • Hi AriHossen,

    It seems that Frank L. Smith solved your issue now, please remember to close your thread by marking Frank L. Smith's post as answer, it is very beneficial to other community members who face the same issue.

    Thanks for your understanding.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, July 19, 2017 7:36 AM