Quick question.. Commondialog allows you to select a file.. what do u use to select a file? Also, how would you add this file to a listbox once its been chosen? Thanks
Private Sub Command1_Click()
CommonDialog1.ShowOpen
List1.AddItem (Left(CommonDialog1.FileName, Len(CommonDialog1.FileName) - Len(CommonDialog1.FileTitle)))
End Sub
in the General Tab at your left, there is a icon with a picture of a folder...thats a DirListBox control... u can add also a DriveListBox or a FileListBox, if u need some code to handle this just post again...
that is a treeview control, it is much more complex to do it, because u got to add nodes, icons, subnodes...
i choose another way if i were you, but if u want to do it with a treeview here it goes some code i copy/paste from MSDN Library:
Nodes Property Example
This example adds several Node objects to a TreeView control. When the form is clicked, a reference to each Node is used to display each Node object's text. To try the example, place a TreeView control on a form and paste the code into the form's Declarations section. Run the example, and click the form.
Private Sub Form_Load()
Dim nodX As Node
Set nodX = TreeView1.Nodes.Add(,,"R","Root")
Set nodX = TreeView1.Nodes.Add("R", tvwChild,"C1","Child 1")
Set nodX = TreeView1.Nodes.Add("R", tvwChild,"C2","Child 2")
Set nodX = TreeView1.Nodes.Add("R", tvwChild,"C3","Child 3")
Set nodX = TreeView1.Nodes.Add("R", tvwChild,"C4","Child 4")
nodX.EnsureVisible
TreeView1.Style = tvwTreelinesText ' Style 4.
TreeView1.BorderStyle = vbFixedSingle
End Sub
Private Sub Form_Click()
Dim i As Integer
Dim strNodes As String
For i = 1 To TreeView1.Nodes.Count
strNodes = strNodes & TreeView1.Nodes(i).Index & " " & _
"Key: " & TreeView1.Nodes(i).Key & " " & _
"Text: " & TreeView1.Nodes(i).Text & vbLF
Next i
MsgBox strNodes
End Sub
the dirlistbox and drivelist box are controls. you have to put them on a form. put the form show command behind a button and you are all set.
if you use the treeview, it is more professional looking, but its much harder to program for, and you have to use a callback to set its starting directory.