Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Treeview Directory Structure

Status
Not open for further replies.

MadCatmk2

Programmer
Joined
Oct 3, 2003
Messages
145
Location
GB
Hi all

I've searched the through a number of posts and haven't found one that gives me a solution to my problem. If i've missed one please direct me to it.

I'd like to write a program that uses the treeview to view all the drives, directories and files on a PC and drill down through them when the user clicks on them in the treeview. I have the treeview on my form but i'm really not sure how to go about populating it with the drive and directory details (Where to start).

I'd appreciate it if someone could point me to a tutorial or could possibly suggest a starting point for me.
I'm relatively new to VB and am sure that its probably not as hard as it first seems, i just need a push in the right direction.

Any help would be most appreciated.
Thanks in advance
 
You are probably looking for the Dir keyword. There is a good example in VBHelp

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
That's already there in VB. On the toolbar you have a DriveListBox (automatically populates with all the drives on your pc), DirListBox (list all the directories in the specified drive) and FileListBox (list all the files in the specified directory)

It's just a matter of getting your hands dirty with these but they are wasy to use. Good luck !

Regards,

Patrick
 
That's not what you are looking for, sorry if I put you on the wrong track. Hmmm, maybe next time I'll read the post fully before jumping in.

:-(

Patrick
 
Redsmooth

It turns out that i think if i use all of the list boxes mentioned in conjunction with the treeview i can populate the treeview with the details i need. Your suggestion was more helpful than you initially thought yourself :-) I will certainly post again if my problems continue but so far so good.

Thanks

 
MadCatmk2,
1st, why not use the common dialog control for a drive and file list. It is a basic tree view and does most of the work for you.

2nd, using the MS Treeview is easy enough.
a) you can manually populate by looping through your data and setting appropriate unique keys for each line.

There really is code out there, I simply read the VB6 help file for this control. If you do need a bit of code - see below for setting treeview's lines and unique keys.
-------------------
Set nodX = EventView.Nodes.Add(, , eventString, eventString & " Event Cust Vessel Agent Port OM # XMIT Flpd Costed")
Set nodFirst = nodX ' just remember the first node
nodX.ForeColor = RGB(200, 10, 210)
lastDEPT = nullString
While Not .EOF
' First node is date
If currentEventID <> !rfqEVENTID Then
RFQEvent.rfqEVENTID = !rfqEVENTID
uniqueNum = uniqueNum + 1
dateStr = packspace(Str$(!dateBIDdue), 10, "R")
dateChecking = Format(!dateBIDdue, "mm/dd/yy")
If Format(!dateBIDdue, "mm/dd/yy") = lastdateStr Then
dateStr = Space(10)
Else
If firstNodeIsSet Then
dateUniqueKey = Format(!dateBIDdue, "mm/dd/yy") & " " & uniqueNum
Set nodX = EventView.Nodes.Add(eventString, tvwChild, dateUniqueKey, packspace(Format(!dateBIDdue, "dddd"), 10, "L") & " Cust Vessel Agent Port # XMIT Flpd Costed")
lglCurrentNodeKey = nodX.Parent.Key
uniqueNum = uniqueNum + 1
End If
End If
lastdateStr = Format(!dateBIDdue, "mm/dd/yy")
ownersMaterial = " "
-------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top