|
-
Sep 24th, 2000, 11:27 AM
#1
Thread Starter
Fanatic Member
I need to use the ListView to nevigate through the
windows files.
Can I do that and how?
-
Sep 24th, 2000, 01:39 PM
#2
Here you go .
You first need a listview, an imagelist with 2 images, the 1st for folder and the 2nd one for file, and an "GO UP" command button. Use default names.
Code:
Option Explicit
Private fso As New FileSystemObject
Private fl As File
Private fls As Files
Private fld As Folder
Private fldl As Folder
Private currfldr As String
Private Sub Command1_Click()
Dim itmp As Byte, xc As Boolean
Set fld = fld.ParentFolder
Set fls = fld.Files
ListView1.ListItems.Clear
For Each fldl In fld.SubFolders
ListView1.ListItems.Add , , fldl.Name, 1, 1
itmp = fldl.Attributes
If itmp >= 128 Then itmp = itmp - 128
If itmp >= 64 Then itmp = itmp - 64
If itmp >= 32 Then itmp = itmp - 32
If itmp >= 16 Then itmp = itmp - 16
If itmp >= 8 Then itmp = itmp - 8
If itmp >= 4 Then itmp = itmp - 4
If itmp = 2 Or 3 Then ListView1.ListItems(ListView1.ListItems.Count).Ghosted = True
Next
For Each fl In fls
ListView1.ListItems.Add , , fl.Name, 2, 2
itmp = fl.Attributes
If itmp >= 128 Then itmp = itmp - 128
If itmp >= 64 Then itmp = itmp - 64
If itmp >= 32 Then itmp = itmp - 32
If itmp >= 16 Then itmp = itmp - 16
If itmp >= 8 Then itmp = itmp - 8
If itmp >= 4 Then itmp = itmp - 4
If itmp = 2 Or 3 Then ListView1.ListItems(ListView1.ListItems.Count).Ghosted = True
Next
Exit Sub
End Sub
Private Sub Form_Load()
Dim itmp As Byte
ListView1.Sorted = True
ListView1.Checkboxes = True
currfldr = "C:\"
Set fld = fso.GetFolder(currfldr)
Set fls = fld.Files
For Each fldl In fld.SubFolders
ListView1.ListItems.Add , , fldl.Name, 1, 1
itmp = fldl.Attributes
If itmp >= 128 Then itmp = itmp - 128
If itmp >= 64 Then itmp = itmp - 64
If itmp >= 32 Then itmp = itmp - 32
If itmp >= 16 Then itmp = itmp - 16
If itmp >= 8 Then itmp = itmp - 8
If itmp >= 4 Then itmp = itmp - 4
If itmp = 2 Or 3 Then ListView1.ListItems(ListView1.ListItems.Count).Ghosted = True
Next
For Each fl In fls
ListView1.ListItems.Add , , fl.Name, 2, 2
itmp = fl.Attributes
If itmp >= 128 Then itmp = itmp - 128
If itmp >= 64 Then itmp = itmp - 64
If itmp >= 32 Then itmp = itmp - 32
If itmp >= 16 Then itmp = itmp - 16
If itmp >= 8 Then itmp = itmp - 8
If itmp >= 4 Then itmp = itmp - 4
If itmp = 2 Or 3 Then ListView1.ListItems(ListView1.ListItems.Count).Ghosted = True
Next
End Sub
Private Sub ListView1_ItemCheck(ByVal Item As MSComctlLib.ListItem)
Dim itmp As Byte
If Item.Icon = 2 Then GoTo extfile
currfldr = currfldr & Item.Text & "\"
Set fld = fso.GetFolder(currfldr)
Set fls = fld.Files
ListView1.ListItems.Clear
For Each fldl In fld.SubFolders
ListView1.ListItems.Add , , fldl.Name, 1, 1
itmp = fldl.Attributes
If itmp >= 128 Then itmp = itmp - 128
If itmp >= 64 Then itmp = itmp - 64
If itmp >= 32 Then itmp = itmp - 32
If itmp >= 16 Then itmp = itmp - 16
If itmp >= 8 Then itmp = itmp - 8
If itmp >= 4 Then itmp = itmp - 4
If itmp = 2 Or 3 Then ListView1.ListItems(ListView1.ListItems.Count).Ghosted = True
Next
For Each fl In fls
ListView1.ListItems.Add , , fl.Name, 2, 2
itmp = fl.Attributes
If itmp >= 128 Then itmp = itmp - 128
If itmp >= 64 Then itmp = itmp - 64
If itmp >= 32 Then itmp = itmp - 32
If itmp >= 16 Then itmp = itmp - 16
If itmp >= 8 Then itmp = itmp - 8
If itmp >= 4 Then itmp = itmp - 4
If itmp = 2 Or 3 Then ListView1.ListItems(ListView1.ListItems.Count).Ghosted = True
Next
Exit Sub
extfile:
Shell currfldr & Item.Text, vbNormalFocus
End Sub
-
Sep 24th, 2000, 01:49 PM
#3
Thread Starter
Fanatic Member
Thanks
but when I try to run it, ut tells me that
Private fso As New FileSystemObject
is not user-defined or something.
-
Sep 24th, 2000, 01:54 PM
#4
Sorry, I forgot to tell you...
Add "Microsoft Scripting Runtime" in your project references. That should solve the error .
-
Sep 24th, 2000, 02:00 PM
#5
Thread Starter
Fanatic Member
Thanks, but another problem came up:
it tells me that I need ti initialize my ImageList.
-
Sep 24th, 2000, 02:10 PM
#6
Yes, sorry.
You also have to right click the listview, choose "Properties" on the popup menu, click on "Image Lists", and set all three combos into the imagelist that you've just created .
That should solve everything , but let me know if there is another.
-
Sep 24th, 2000, 02:56 PM
#7
Thread Starter
Fanatic Member
It's great!
But still not perfect.
first of all, why are all the file are CheckBoxes?
and second, on some folders the click does not work?
-
Sep 24th, 2000, 03:21 PM
#8
Well, actually, clicking on a checkbox would open the file/folder, and you click the CHECKBOX, not the icon, to open it. You may need to select a file and there isn't a DOUBLE-CLICK event for individual items .
-
Sep 25th, 2000, 08:08 AM
#9
Thread Starter
Fanatic Member
Well, thanks anyway.
does anyone knows how to solve this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|