populating treeview with disk drives

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 29
Reputation: jbrock31 is an unknown quantity at this point 
Solved Threads: 1
jbrock31 jbrock31 is offline Offline
Light Poster

populating treeview with disk drives

 
0
  #1
Jan 31st, 2009
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.

  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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: populating treeview with disk drives

 
0
  #2
Jan 31st, 2009
Last edited by Comatose; Jan 31st, 2009 at 1:22 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 2,065
Reputation: Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice Ramy Mahrous is just really nice 
Solved Threads: 256
Featured Poster
Ramy Mahrous's Avatar
Ramy Mahrous Ramy Mahrous is offline Offline
Postaholic

Re: populating treeview with disk drives

 
1
  #3
Jan 31st, 2009
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.
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 29
Reputation: jbrock31 is an unknown quantity at this point 
Solved Threads: 1
jbrock31 jbrock31 is offline Offline
Light Poster

Re: populating treeview with disk drives

 
0
  #4
Jan 31st, 2009
Thanks for the link and the encouragement. I will keep working on it hard. Thanks!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC