Listview Icons And Dragging
Is it possible to have the listview Items containing icons not able to drag? If so how?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Dragging Icons
Does anyone know how to click and drag an image or icon like the targeting device in Spy++ or Window Sniper? Any help would be greatly appreciated.
-CD
How To Disable Dragging/dropping The Windows Desktop Icons
Hi, friends,
I want to disable dragging/dropping the Windows desktop icons by a program. How can I do that? (eg. If a user drag an icon and drop it elsewhere, give a warn messagebox).
Also, I want to disable the "New" submenu in the pop-up menu after Right-clicking the mouse on the Windows desktop. How can I do
that by a program?
Highly appreciated!
ListView DRAGGING
How can I select multiple items by clicking and then dragging over the amount of records that are there?
thanks...
Listview - Turning Off Dragging
I'm in one of my old apps and noticed that for some reason I used a listview control when a listbox "might" have done the job. My comments aren't as good as they should be (lesson learned). Anyway, since I'm not sure why I used a listview instead of a listbox I'm not willing to replace it. I don't have the time.
So... Is there a property (that I can't find) that turns off dragging of items in the listview control?
Thanks,
Bernie
Dragging Listview Items
How to drag Listview Item to another form with the same format of Listview.??? hElp please??
Listview Dragging Item
Hello, Jusk asking if there is a possible way to drag item in the listview??
it goes like this:
Listview populate with;
Item 1
Item 2
Item 3
When I drag Item 3 to the position of Item2, it goes like this;
Item 1
Item 3
Item 2
is this possible?? if not?? what should I do??
ListView And Turning Off Dragging
I have Listview with a number of items and I want a user to be able to select an item by clicking on it. Currently, if they click and drag then the icon and text go flying all over the window. How do you keep them from being able to click and drag on the icons messing up the entire list view but still allow them to click and select one? There are a number of related posts but noone seems to have a straightforward answer and this seems easy. Help please!
Thanks.
Create Shortcut By Dragging From Listview
Was wondering if someone could show me an example of creating a windows shortcut by dragging an item out of a listview control and say onto the desktop.
When creating the shortcut I would like to link to a specifix .exe, but use what was dragged out as part of the command line parameters.
Thanks in advance
Listview: Disabling User Dragging
Is there a way to disable the user from dragging items in a listview. My listview.view=lvwIcon and has to stay that way (e.g. I need the nice large icons)
Thanks in advance,
Listview Setting No Column Dragging
Hi all
you know how with the listview columns you can drag them?
howdo i stop this or get it to resize as soon as the user drags it so its kind of asking howto set the drag to be undraggable
Tom
Dragging Multiple Items From A Listview
i have some code to let users drag an item from a listview onto a treeview node, which works fine, but now i want to let them drag multiple items.
the problem is that when then select a bunch of items, then drag them to the treeview, it leaves only the last item they clicked on selected (as if they selected them, then just left-clicked one of them). is there a way to keep them all selected?
also, just out of interest, is there a way to make the drag icon include some text from each selected listview item along with an icon (like when you drag multiple files in windows explorer)?
thanks for any help
Problem With ListView Control And Dragging
I'm trying to drag an item from one ListView control to another but whenever I click on any of the items the first item is selected no matter which I have clicked on. The drag outline does appear over the selected object though. The ListView control is in report view and all the other relevant code is below, can anyone suggest what I've done wrong?
Many thanks
Geoff
Setting up control:
Dim itmX As ListItem
lsvEvents.ListItems.Clear
lsvEvents.ColumnHeaders.Clear
lsvEvents.ColumnHeaders.Add , "Event", "Event", lsvEvents.Width / 2
lsvEvents.ColumnHeaders.Add , "Time", "Time", lsvEvents.Width / 2
lsvEvents.SmallIcons = imlLog
For each record in a recordset:
Set itmX = lsvEvents.ListItems.Add()
itmX.Text = !Name
itmX.Tag = !EventID
itmX.SubItems(1) = !OpenTime
Select Case !EventType
Case Is = "<Project File>"
itmX.SmallIcon = "Project"
Case Is = "<Resource File>"
itmX.SmallIcon = "Resource"
Case Is = "<Issue>"
itmX.SmallIcon = "Issue"
End Select
MouseDown:
Private Sub lstEvents_MouseDown(Button As Integer, Shift As Integer, x As
Single, y As Single)
Dim DY ' Declare variable.
DY = TextHeight("A") ' Get height of one line.
lblDrag.Move lstEvents.Left, lstEvents.Top + y - DY / 2, lstEvents.Width,
DY
lblDrag.Drag ' Drag label outline.
End Sub
Problem With ListView Control And Dragging
I'm trying to drag an item from one ListView control to another but whenever I click on any of the items the first item is selected no matter which I
have clicked on. The drag outline does appear over the selected object though. The ListView control is in report view and all the other relevant code is below, can anyone suggest what I've done wrong?
Many thanks
Geoff
Setting up control:
Dim itmX As ListItem
lsvEvents.ListItems.Clear
lsvEvents.ColumnHeaders.Clear
lsvEvents.ColumnHeaders.Add , "Event", "Event", lsvEvents.Width / 2
lsvEvents.ColumnHeaders.Add , "Time", "Time", lsvEvents.Width / 2
lsvEvents.SmallIcons = imlLog
For each record in a recordset:
Set itmX = lsvEvents.ListItems.Add()
itmX.Text = !Name
itmX.Tag = !EventID
itmX.SubItems(1) = !OpenTime
Select Case !EventType
Case Is = "<Project File>"
itmX.SmallIcon = "Project"
Case Is = "<Resource File>"
itmX.SmallIcon = "Resource"
Case Is = "<Issue>"
itmX.SmallIcon = "Issue"
End Select
MouseDown:
Private Sub lstEvents_MouseDown(Button As Integer, Shift As Integer, x As
Single, y As Single)
Dim DY ' Declare variable.
DY = TextHeight("A") ' Get height of one line.
lblDrag.Move lstEvents.Left, lstEvents.Top + y - DY / 2, lstEvents.Width,
DY
lblDrag.Drag ' Drag label outline.
End Sub
Stop Item Dragging/moving In ListView
Is there any way you can stop the user from moving the item position in a listview?? I need them to stay the same as i added them first by code, with them being fixed for the user and not allowing any movement of item position!
thanks!
Please Double Check This Dragging From ListBox To ListView Code For Me
I want to drag an item from a listbox to a listview so starting with my lisbox code:
Private DragID As Integer
Private blnAmDragging As Boolean
Code:
Private Sub lstUnalloc_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbLeftButton Then
DragID = lstUnalloc.ItemData(lstUnalloc.ListIndex)
End If
End Sub
Code:
Private Sub lstUnalloc_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
On Error GoTo errh
If Button = vbLeftButton Then
If lstUnalloc.ListIndex >= 0 Then
blnAmDragging = True
lstUnalloc.Drag vbBeginDrag
End If
End If
Exit Sub
errh:
errmsg "The following Exception occured : " & Err.Description & ", " & Err.Source & "", "Exception occured in frmMain.lstUnalloc_MouseMove ()"
End Sub
and now my listview:
Code:
Private Sub lvwPeople_DragOver(Source As Control, x As Single, y As Single, State As Integer)
On Error GoTo errh
If blnAmDragging = True Then
If State = vbLeave Then
Set lvwPeople.DropHighlight = Nothing
Else
Set lvwPeople.DropHighlight = lvwPeople.HitTest(x, y)
End If
End If
Exit Sub
errh:
errmsg "The following Exception occured : " & Err.Description & ", " & Err.Source & "", "Exception occured in frmMain.lstlist_DragOver()"
End Sub
Code:
Private Sub lvwPeople_DragDrop(Source As Control, x As Single, y As Single)
If Source = "lvwPeople" Then
Exit Sub
End If
Source.Drag vbEndDrag
Set lvwPeople.SelectedItem = lvwPeople.HitTest(x, y)
MsgBox lvwPeople.SelectedItem.Key
MsgBox DragID
End Sub
I just put 2 msgboxes to test. I have to write sql statements to assign the number to a person. I just need someone to check if I am doing the correct stuff for dragging and dropping.
Listview - Icons
hello folks,
for my latest project I am working on iw ould like to have a listview (reportstyle) with several items in it. For a more "spreadsheet-like-look" I have the gridlines on.
What I would like to do now is to indicate with an icon what item the user selected. So when the user clicks an item a little arrow-like icon appears before in front of the selected line and the icon disappears on the item that was previously selected.
I was thinking to first remove all the markers and then place a marker on the selected item (this because I don't know a method to check the previously selected Item)
for code I have this:
Code:
Private Sub lsvContracts_Click()
Dim NrOfItems As Integer
'remove marker from previous selected item
NrOfItems = lsvContracts.ListItems.Count
For i = 1 To NrOfItems
lsvContracts.ListItems(i).SmallIcon = 0 'no marker should displayed
Next i
lsvContracts.Refresh
'put marker before selected Item
lsvContracts.SelectedItem.SmallIcon = 2
End Sub
this just doesn't seem to be working, I just don't know what to do next.
Does anybody have an Idea how to solve this!!
Listview Icons
I have icons on a listview but I cant get them to line up beside the listitems :
code:
ListView1.View = lvwReport
ListView1.ColumnHeaders.Add , , "Total Users"
ListView1.ColumnHeaders.Add , , "Members"
For UserLoop = LBound(Usernames) To UBound(Usernames)
Set itmX = ListView1.ListItems.Add(, , Usernames(UserLoop))
ListView1.ListItems.Add , , LivveIcon, , 1
Set itmX = Nothing
Next
Can someone plz help?
Icons In Listview
how can i add an icon in a listview. I've searched the forum already and i have to set the imagelist first in the properties, but they are all empty and i dont know how to add something in it. So can anyone help me with this please, how to put the icons in it, and what to do next from there.
Listview Icons
Hi Everyone,
I have a list view box and I would like to place an Icon on each line.
The list view has subitems so it needs to be viewed in the Report View format.
Any ideas?
BDS
>>> ListView And Icons <<<
Hello, all together!
My problem is that:
When I select an entry with an icon of a ListItem control, the icon is/was selected, too. How can I avoid now, that the icon is selected?
Thanks for Help, Marco.
Listview Icons
i have this code to put as icon in my listview
Code:
ListView1.ListItems.Add() = Text1.Text
ListView1.Icons = ImageList1.ListItems
but it doesn't work.Because is the first time i use this property i don't know nothing so i want help as much as you can
ListView Icons
I'm displaying different types of data in a ListView control. Some data types have icons, some do not. All the data with icons are displayed together and all the data without icons are displayed together after the Listview has been cleared. After displaying data with icons, when data is displayed without icons the text stays shifted to the right as if there was still an icon there. Is there a way to move the text back to the left when no icon is displayed? I've tried setting the view to lvwReport or lvwList and refreshing the ListView control but it hasn't worked. Thanks for the help!
ListView + Icons
Hello, it's me again
I have a ListView control returning a transaction history, with succeeded transactions, transaction warnings and transaction errors. Right now, it's just plain text. I would like to put an icon in front of each line, depending on the type off message (Suc., Warn., Err.). Can I do this in my ListView or would you replace it with a grid ?
Greetz,
Yoda
<font color=green>Do or do not
There is no try</font color=green>
ListView Icons
I've added little up and down arrows to indicate how my listview is sorted. What's bugging me is that I cant figure out how to tell a columnheader object that it is to have no icon: i.e. the listview is sorted by another column. How do I de-select an icon in this instance?
Thanks.
ListView Icons
Hello!
I was wondering if it is possible to add images to a ListView controls without needing an ImageList control.
I am re-writing a program which connects to Amazon and downloads CD/DVD covers. If the user enters an unspecific keyword like "Pink Floyd" for example, a lot of images will be returned in the XML file Amazon provides because there are a lot of CDs and DVDs made by Pink Floyd. Let's say 200 images are available. At the moment, the program operates in the following way:
Connect to Amazon and pass subscription ID, keywords, media type...Fetch the "index" XML file Amazon generated and obtain the total number of pages.Loop though all pages and for each page, loop trough the items and look if an image is available. If an image is available, store the URL in an array.Terminate the connection.If the image URL array is not empty, loop through the array and download all files. After each image was downloaded, load it into the ImageList control.After the ImageList control is full of images, start another loop which adds items to the ListView and connect the ImageList with the ListView so the images appear as thumbnails.As you can see, there are a lot of loops there. While the loops in step 3 cannot be avoided (since I have to loop through all pages and all items of the individual pages), I was wondering if I can somehow avoid the other loops by directly adding an item to the ListView and load an image from the disk (rather than from an ImageList).
Any idea if this is possible?
Regards,
Sebastian
Help - Icons In A Listview
Hey,
I need some help with this. Made a search here in the forum but still can't figure it out.
The Listview View property is Report and I would like to add items to a listview with an icon next to each item. The icon is the same for all items.
The ImageList already holds the Icon. I get error Invalid Key
Code:
.listFiles.ListItems.Add , , FileName, , .ImageList1.ListImages.Item(1)
Thanks
ListView Icons...
How can I get an icon/picture to appear in the listview column header, to the RIGHT of the caption?
At the moment, they are all going to the left, which I don't like...
Listview Icons
I have icons on a listview but I cant get them to line up beside the listitems :
Code:
ListView1.View = lvwReport
ListView1.ColumnHeaders.Add , , "Total Users"
ListView1.ColumnHeaders.Add , , "Members"
For UserLoop = LBound(Usernames) To UBound(Usernames)
Set itmX = ListView1.ListItems.Add(, , Usernames(UserLoop))
ListView1.ListItems.Add , , LivveIcon, , 1
Set itmX = Nothing
Next
Can someone plz help?
Listview Icons...
Yeah so I have a listview. Whenever a certain action is fired I want it to add icons to it right? Well I want it to add and Icon for the ping. When lets say someone joines the channel, it gets their ping.
But whenever it adds it to the listview, it will ALWAYS come out the icon number 21. Also, when I view all of the icons, they sometimes appear all jumbled up and weird looking. Like icons all over the place? Here Is my full code for this action.
VB Code:
Private Sub ee_OnUser(Username As String, Flags As Byte, Message As String, Ping As Integer)main.lchannel.Caption = ""main.lchannel.Caption = main.ee.CurrentChannelDim IconNumber As IntegerDim PingNumber As IntegerDim strRealProduct As StringIf Ping <= 99 ThenPingNumber = 16End IfIf Ping <= 199 ThenPingNumber = 17End IfIf Ping <= 299 ThenPingNumber = 18End IfIf Ping <= 399 ThenPingNumber = 19End IfIf Ping <= 499 ThenPingNumber = 20End IfIf Ping <= 600 ThenPingNumber = 21End IfIf Ping >= 600 ThenPingNumber = 21End If'ignore this stuff it worksIf ReverseString(Left(Message, 4)) = "blaah" ThenIconNumber = 10strRealProduct = "blaah"ElseIf ReverseString(Left(Message, 4)) = "blaah" ThenIconNumber = 7strRealProduct = "blaah"ElseIf ReverseString(Left(Message, 4)) = "blaah" ThenIconNumber = 11strRealProduct = "blaah"ElseIf ReverseString(Left(Message, 4)) = "blaah" ThenIconNumber = 6strRealProduct = "blaah"ElseIf ReverseString(Left(Message, 4)) = "blaah" ThenIconNumber = 14strRealProduct = "blaah"ElseIf ReverseString(Left(Message, 4)) = "blaah" ThenIconNumber = 62strRealProduct = "blaah"ElseIf ReverseString(Left(Message, 4)) = "blaah" ThenIconNumber = 2strRealProduct = "blaah"ElseIconNumber = 64End IfIf Flags = 2 ThenIconNumber = 1End IfIf Flags = 18 ThenIconNumber = 1End IfIf Flags = 16 ThenPingNumber = 22End If'stop ignoringIf main.lchannel.Caption = main.ee.Home Thenmain.lpeople.Caption = main.lvchannel.ListItems.Count + 1AddChat vbCyan, Username, vbRed, " is in " + main.ee.CurrentChannel + " with ", vbCyan, Flags, vbRed, " flags, ", vbCyan, Ping, vbRed, " ping, using, ", vbCyan, strRealProduct, vbRed, "." If IconNumber = 1 Thenmain.lvchannel.ListItems.Add 1, , Username, , IconNumbermain.lvchannel.SelectedItem.ListSubItems.Add , , , PingNumber ElseIf Username = main.ee.Username Thenmain.lvchannel.ForeColor = &H80000004main.lvchannel.ListItems.Add , , Username, , IconNumbermain.lvchannel.SelectedItem.ListSubItems.Add , , , PingNumbermain.lvchannel.ForeColor = &HFFFF& Else With main.lvchannel.ListItems.Add(, , Username, , IconNumber).ListSubItems.Add , , , PingNumberEnd WithEnd IfEnd If End Sub
I know for a fact that my icon code numbers are right in the ImageList. Thanks for your help.
Big Icons In Listview
Hey guys!
I am having a bad time with listview.
I can put data inside of list view without trouble.
I created an imagelist and I put 2 icons inside of it, and I made the listview get both images from imagelist and show beside of the name of each column ( I have 2). The problem are 2:
1- The icons are very very big beside the name of each column
2- Each registry in the list view are receiving an icon too....And I dont want... =-(
Here is my code
VB Code:
Private Sub ConfiguraLv()Set ListView1.ColumnHeaderIcons = ImageList1Set ListView1.Icons = ImageList1Set ListView1.SmallIcons = ImageList1Dim clmx As ColumnHeaderSet clmx = ListView1.ColumnHeaders.Add(, , "column 1", , , 1)Set clmx = ListView1.ColumnHeaders.Add(, , "column 2", , , 2)Dim itmx As ListItemSet itmx = ListView1.ListItems.Add(, , "data1(0)", , 1)itmx.SubItems(1) = "data1(1)"End Sub
Thanks for your time,
Elminster
Icons And Listview
Hi there,
I am able to fill a listview and show an icon on each listitem.
Now I want to show a different icon when the user selects a particular listitem in the listview.
Does anybody know how to do this?
Many thanx!
Listview Icons
I am using a listview for the data i retrieve from my sql server.
When i retrieve the information i want to give every brand there own logo(icon).
So for example: when i retrieve 'NIKE', the listview have to put the nike icon from my imagelist in the listview. But what if i retrieve 2 different brands like 'NIKE' and 'ADIDAS', how can i give them the good icons?
this is my current code:
VB Code:
While Not rs.EOF Set itmX = lv.ListItems.Add(, , "" & rs(0), , 3) itmX.SubItems(1) = "" & rs(1) rs.MoveNextWend
Icons In ListView
Hi
I have a listview with 3 columns in it. column1 holds a name, column2 holds a phone number, column3 holds a subject. I want to put an icon next to the subject in column3. How is this done?
Thanking you in advance
PORRASTAR
Listview Icons
Is it possible to add my own icons in a listview?
Also, can I change a particular row's icon? As in, can I be specific in a listview? Coz i'm afraid that if i change an icon, the whole listview will have that icon.
Also, if so, how do I refer to a specific row? All i know now is referring to a specific column, like '.subitem(1)'.
Anybody can help me out?
Listview Icons
two questions
1. i've created an app that lets a user drag items from a treeview into a listview (style is lvwIcon). however, if the text of the item that's dragged is quite long, then it overlaps other items in the listview. is there anyway to prevent that?
2. this isn't very important, but if the user drags the items in the listview over to the edges of the listview, it starts scrolling. is there any way to prevent that also?
ListView Icons
I want to load in the contents of the Desktop into a listview control. I also want the items to have the same icon that they have on the desktop. How can I do this? I don't want to use FSO so I use a File box and loop through the files. I tried the ExtractIcon API but it didn't work on files and the like.
Thanks for any help
-Joey
ListView Icons
Hi,
How can i show the standard icons of files on my pc, next to it's name in a listview?
For example if the files in the listview are:
Book1.xls
Doc1.doc
Stuff.pdf
How can i show the excel document icon nect to Book1.xls, and the word document icon next to Doc1.doc and the PDF icon next to Stuff.pdf?
Listview Icons
Hi all
Why is it that when i use an icon straight from an imagelist into a listview the icon is clear to see, as it was meant to be, but when i extract an icon from a file(exe) to a picturebox and the copy it to the imagelist, and then to the listview it looks distorted.
Does anyone know how to fix this, or have any code that will extract an icon from a file straight to an image list.
Thanks
Mark
ListView Icons
Until now, my form was working fine. There is a form I
have called frmUserList. It has a listview control
which displays a list of users in the Icon view with
small icons. Until now for the last 2 months it has
been working fine, I got a designer to make new images
for the GUI of the whole application and now its
suddenly giving me an error. Here's the code from the
load event of the form frmUserList.
Private Sub Form_Load()
Call FillUserListView
gSelectedUserName = vbNullString
CenterForm Me
End Sub
Public Sub FillUserListView()
Dim rs As Recordset
Dim StrUserName As String
With lstvwUsers
.ListItems.Clear
.View = lvwIcon
.HideSelection = False
.SortKey = 0
.SortOrder = lvwAscending
.Sorted = True
Set .Icons = MDI.imglst
Set rs = PMData.GetData("select [User Profile -
Current Status].* from [User Profile - Current
Status]")
If rs.RecordCount = 0 Then
If rs.State <> adStateClosed Then rs.Close
If Not rs Is Nothing Then Set rs = Nothing
Exit Sub
End If
Do
StrUserName = rs("User Name")
.ListItems.Add , StrUserName, StrUserName, ,
"imgUser"
rs.MoveNext
Loop Until rs.EOF
If rs.State <> adStateClosed Then rs.Close
If Not rs Is Nothing Then Set rs = Nothing
End With
End Sub
Now that I've made some changes to the GUI as in
removed all the previous pics and added new ones and
changed all forms, I get this error.
"ImageList must be initialized before it can be used"
Please don't tell me I have to set the ImageList for
each type at design time. It's been working fine till
now until before I got this error.
Regards,
Sathyaish Chakravarthy.
ICons In Listview
Hello
How can i get file-type Icons into a listview ?
I can get the filetype Icon but i cannot put it into the listview.
ListView With Icons
Good Morning
Say you have a Table like This:
EMPLOYEES
Name text 50 chars
Surname text 50 chars
Photo ole
I would like to use the listview to show a list of the employees as follows:
Photo Surname Name
I have coded as:
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim ItmX As ListItem
Set db = OpenDatabase("DATABASE.MDB")
strSQL = "SELECT * FROM EMPLOYEES
Set rs = db.OpenRecordset(strSQL,dbOpenForwardOnly)
Do Until rs.EOF
Set ItmX = ListView1.ListItems.Add(, , rs!PHOTO)
ItmX.SubItems(1) = rs!NAME
ItmX.SubItems(2) = rs!SURNAME
rs.MoveNext
Loop
I would like the photo appears in the list as an icon.
But of course id doesn't work.
Have you got an idea about?
Thanks for yr help.
Regards
TdP
Icons For Listview
I have a list box that I fill with files from a filebox.
This part I am able to do,
the part i have trouble with is getting the icon to go with these files.
Specificly i want the icon associated with their filetype.
How can I add icons to the imagelist during runtime?
Or do i do it a different way?
thanks
jollygreengiant
ps. where can i find the icons associated with explorer
i.e. open folder, desktop icon, my computer icon etc.
I found the 32x32 icons for these in shell32.dll,
but the 16x16 version, the one i would use in my list/treeviews are
butt ugly and messed up
Where are the one that explorer uses stored?
thanks again,
jollygrengiant
Edited by - JollyGreenGiant on 11/14/2003 7:10:54 AM
ListView Icons?
Is there a way to access the icons of a listview from the Icons property? It would seem only obvious, but trying to do something like:
Dim oImage as ListImage
Set oImage = myListView.Icons(1)
...causes an error (object doesn't support this property). There is an image list control associated to the list view. I hope I don't have to access the image list for the icon. For example with a treeview control you can do:
Dim oImage as ListImage
Set oImage = myTreeView.ImageList.ListImages(1)
It doesn't look like the ListView lets you access the images like this. It's nice in procedures where I'm passing in the listview or treeview as an argument because I don't have to pass in the imagelist also.
Listview Icons
I need the icons to be displayed with the file names. I need the icons to be the ones that are associated with the file type (.txt files have Text File icons). This code displays the list of files (List1, and ListView1):
Code:
Option Explicit
Private Sub Command1_Click()
' add a Reference to Microsoft Scripting Runtime
Dim fso As New FileSystemObject
Dim objFolder As Folder
Dim objFile As File
Dim xItem As ListItem
Dim intX As Integer
Dim objSize
For intX = 0 To List1.ListCount - 1
'check to see if dir exists
If (GetAttr(List1.List(intX)) And vbDirectory) = vbDirectory Then ' this is a directory
' the folder to verify
Dim strFolderName As String
strFolderName = List1.List(intX)
' get that folder
Set objFolder = fso.GetFolder(strFolderName)
' loop thru all the files in the folder and add to listview
For Each objFile In objFolder.Files
Set xItem = ListView1.ListItems.Add
xItem.Text = objFile.Name
objSize = objFile.Size / 1024
' round up to the next KB
objSize = Int(objSize) + Abs(CBool(objSize - Int(objSize)))
xItem.SubItems(1) = Format$(objSize, "#,##0 KB")
xItem.SubItems(2) = Format(objFile.DateLastModified, "dd/mm/yyyy h:mm ampm")
xItem.SubItems(3) = objFile.Type
xItem.SubItems(4) = objFile.ParentFolder
Next
'Destroy the objects
Set xItem = Nothing
Set objFile = Nothing
Set objFolder = Nothing
Set fso = Nothing
End If
Next intX
End Sub
Private Sub Form_Load()
List1.AddItem "C:"
End Sub
Tell me if I need to explain anymore.
|