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 :)
Printable View
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 (CommonDialog1.FileName)
End Sub
thats for a file - how about a folder?
here it is...
Private Sub Command1_Click()
CommonDialog1.ShowOpen
List1.AddItem (Left(CommonDialog1.FileName, Len(CommonDialog1.FileName) - Len(CommonDialog1.FileTitle)))
End Sub
hmm.. but is there anyway to just load up a dialog that contains folders only? Ive seen them before.. just dont know how to call them up
use a DirListBox control for that...
hehe sorry bout the newbie questions, but how would i do that?
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...
Thanks :). One final question.. in Command1_Click, how would I popup a diablog, like commondialog, for a person to select a folder?
to popup a commondialog just:
commondialog1.showopen
a commondialog for folders tho :) not files.. like a commondialog with a dirlistbox instead of its selection of files
just have a look on this, perhaps it will help u...
how about something like this? (note the part in the black rectangle)
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
hope this can help you...
tanks :). If you or anyone else manages to get that to work, let me know (to make it look like that image)
not today, because it is very late, but i will try to make an example of a treeview like the image that you upload and i will send it by email...
nm :) Found it! Thanks for all your help :)
Heres a link to it if ya like
http://www.planetsourcecode.com/xq/A...s/ShowCode.htm
the pic is of the system drive list box.
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.