Hello everyone.
Can anyone give a link to a good guide/tutorial on how to populate a treeview with the drives of a system. I am able to get the drives listed, but am i having a problem creating the child nodes for the drives and really have never used a tree view before. Any info is appreciated.
Below is what i have tried ( just to show my attempt). i know its wrong, so any tutorials or advice is appreciated.
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With tvDrives
.BeginUpdate()
For Each dr As DriveInfo In DriveInfo.GetDrives()
.Nodes.Add(dr.Name)
Next
.EndUpdate()
End With
End Sub
Private Sub tvDrives_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvDrives.AfterSelect
With tvDrives
For Each dr As DriveInfo In DriveInfo.GetDrives()
Dim dir As New DirectoryInfo(dr.Name) ' i want to try and use the selected node, but i am having trouble figuring this out and i just used this instead to make it work temporarily.
.ShowPlusMinus = True
For Each d As DirectoryInfo In Dir.GetDirectories()
Dim count As Integer = 0
.Nodes(count).Nodes.Add(d.Name)
count += 1
Next
Next
End With
End Sub
End Class