Click to See Complete Forum and Search --> : adding items tolistview
mevasquez
August 30th, 2001, 10:55 AM
Can't figure out why this don't work. Have looked at examples and still having problem. Here's the code:
Getting error "Type Mismatch"
private Sub AddFileToListView(strFileName as string, FileDate as date)
Dim li as ListItem
set li = ListView1.ListItems.Add(, , strFileName)
With li
.SubItems(1) = strFileName
.SubItems(2) = FileDate
End With
End Sub
I get a file name listed for strFileName, however, I can't get the FileDate to be listed. Any suggestions?
berta
August 30th, 2001, 11:12 AM
have U add columns with listview form page?
at design time, right button on listview and choose property.
<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/images/bertaplanet.gif'>
</center>
berta
August 30th, 2001, 11:13 AM
set view property = 3 'report
<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/images/bertaplanet.gif'>
</center>
mike@work
August 30th, 2001, 11:55 AM
Yes at design times colums are set
column 1 = File Name
column 2 = File Date
mike@work
August 30th, 2001, 12:04 PM
Did not work. Now I got it to list the file name in the column "File Name" and also the file name is listed in column "File Date"
private Sub AddFileToListView(strFileName as string, FileDate as date)
Dim li as ListItem
Lv1.View = lvwReport
set li = Lv1.ListItems.Add(, , strFileName)
With li
.SubItems(1) = strFileName
.SubItems(2) = FileDate 'get error HERE NOW' "error says "Invalid property value"
End With
set li = nothing
End Sub
If I add "on error resume next" I get the file name in the column "File Date".
Any reason why?
mike@work
August 30th, 2001, 12:17 PM
Found solution
set li = Lv1.ListItems.Add(, , strFileName) 'This is .SubItems(0)
With li
.SubItems(1) = FileDate
End With
set li = nothing
berta
August 30th, 2001, 05:20 PM
yeah!
<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/images/bertaplanet.gif'>
</center>
berta
August 30th, 2001, 05:24 PM
U cabn access to item of lisitem for key...
so U have no link to position..
.SubItems("FileName") = strFileName
.SubItems("FileDate") = FileDate
<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/images/bertaplanet.gif'>
</center>
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.