943,667 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 2025
  • VB.NET RSS
Jan 31st, 2009
0

populating treeview with disk drives

Expand Post »
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.

vb Syntax (Toggle Plain Text)
  1. Imports System.IO
  2. Public Class Form1
  3.  
  4. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  5.  
  6. With tvDrives
  7.  
  8. .BeginUpdate()
  9. For Each dr As DriveInfo In DriveInfo.GetDrives()
  10. .Nodes.Add(dr.Name)
  11.  
  12. Next
  13.  
  14. .EndUpdate()
  15. End With
  16.  
  17. End Sub
  18.  
  19. Private Sub tvDrives_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvDrives.AfterSelect
  20.  
  21. With tvDrives
  22.  
  23. For Each dr As DriveInfo In DriveInfo.GetDrives()
  24.  
  25. 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.
  26.  
  27. .ShowPlusMinus = True
  28.  
  29. For Each d As DirectoryInfo In Dir.GetDirectories()
  30. Dim count As Integer = 0
  31. .Nodes(count).Nodes.Add(d.Name)
  32. count += 1
  33. Next
  34.  
  35. Next
  36.  
  37. End With
  38.  
  39. End Sub
  40. End Class
Reputation Points: 22
Solved Threads: 14
Junior Poster in Training
jbrock31 is offline Offline
73 posts
since Oct 2008
Jan 31st, 2009
0

Re: populating treeview with disk drives

Last edited by Comatose; Jan 31st, 2009 at 1:22 pm.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Jan 31st, 2009
1

Re: populating treeview with disk drives

Look, you reached to very good phase.. what you need is to know how to go through nested directories. I believe you can do it on your own.
Featured Poster
Reputation Points: 480
Solved Threads: 276
Postaholic
Ramy Mahrous is offline Offline
2,189 posts
since Aug 2006
Jan 31st, 2009
0

Re: populating treeview with disk drives

Thanks for the link and the encouragement. I will keep working on it hard. Thanks!
Reputation Points: 22
Solved Threads: 14
Junior Poster in Training
jbrock31 is offline Offline
73 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: DATABASE
Next Thread in VB.NET Forum Timeline: small issues...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC