I need to add to my app a ListView that will navigate
through the user's files.
By clicking on the file or folder icon, the
file/folder will be in focus, and I will be able to
open them, extract them and such...
Printable View
I need to add to my app a ListView that will navigate
through the user's files.
By clicking on the file or folder icon, the
file/folder will be in focus, and I will be able to
open them, extract them and such...
the 'FileListBox' control (Which can be used in conjunction with the 'DirListBox' and 'DriveListBox'.
Better still, why not use the MS 'CommonDialog' control as this does the whole job for you.
I have suggested that, but my boss wants it to be with a
listbox to make it look better.
What is it exactly you want to know then? How to populate a list view control? How to find out directory contents?
It's not clear what it is exactly you want to do.
I'll explain:
I need the list view will show a list of files and folders
in a drive. Then by dblClicking on a folder, the listview box will go to content of the folder. By clicking on a
folder or file, the file/folder will be in focus and will
be able to change the file or folder.
For etc, WinZip's listview shows zipped files and folders.
Then, if you click on a file and click "Extarct" it does
something to the file (Unzip it). right?
Now here's something to start withCode:'in declarations
private path as string
'to populate a listview with directories and files...
Dim a As String
a = Dir(path, vbHidden Or vbDirectory)
Do While Len(a)
If GetAttr(a) And vbDirectory Then
ListView1.ListItems.Add a & ", Directory"
Else
ListView1.ListItems.Add a & ", File"
End If
a = Dir
Loop
Try downloading the COMcache Xplorer Control Set from ComponentSource.
It includes three FREE controls where one is the CCXploreListView which mimic the right hand pane of Windows Explorer.
You might have to register at ComponentSource before you're allowed this download, but the registration is free as well.
Best regards
Thanks Joacim!
But tell me, how do I make the listview control
in it to go to a certain folder and show it's content?
[Edited by dekelc on 09-27-2000 at 02:24 AM]
There are three importent properties here. They are:[*] CurrentFolder[*] CurrentNameSpace[*] CurrentType
You set the CurrentFolder to any path that you want to see in the listview.
If you want to see a NameSpace folder such as the Control Panel or the Recycle Bin you set the CurrentNameSpace property to the correct name space.
The CurrentType determents if you should use the CurrentFolder or the CurrentNameSpace. Just set it to one of these values:[*] 0 - ccFolder[*] 1 - ccNameSpace
Good luck!
What is "correct name space"?
??????????????? Que ????????????????????Quote:
Originally posted by dekelc
What is "correct name space"?
What do you mean by "correct name space". The properties was CurrentNameSpace, CurrentFolder, and CurrentType.
Now if you just changed this a bit so that you don't have the ", directory" and stuff shown then you could just test the path and then repopulate the list with files and subdirs from the new path.Code:'in declarations
private path as string
'to populate a listview with directories and files...
Sub RefreshList()
Dim a As String
listview1.listitems.clear
a = Dir(path, vbHidden Or vbDirectory)
Do While Len(a)
If GetAttr(a) And vbDirectory Then
ListView1.ListItems.Add a
Else
ListView1.ListItems.Add a
End If
a = Dir
Loop
End sub
Code:Private Sub ListView1_ItemClick(ByVal Item As ComctlLib.ListItem)
If GetAttr(Path & "\" & Item.Text) And vbDirectory Then
Path = Path & "\" & Item.Text 'It's a folder, go into it
Else
'It's a file, do somthing else?
End If
End Sub