Discussion:
Invalid Property Value
(too old to reply)
Brian
2004-09-10 13:05:18 UTC
Permalink
Can anyone help, I'm using a ListView control from CommControl 6.0, when I
try to fill the listview using the code below, I get a Runtime error 380
Invalid Property Value when executing the first .SubItems line.

Any suggestions?

Sub tempList()
Dim lstStuff As MSComctlLib.ListItem
Dim count%

ListView1.ListItems.Clear

For count = 1 To 3
Set lstStuff = ListView1.ListItems.Add(, "X" & count, "One")

With ListView1
With lstStuff
.SubItems(1) = "Two" & count
.SubItems(2) = "Three" & count
End With
End With
Next count
End Sub


Thanks,
Brian
Björn Holmgren
2004-09-10 13:25:55 UTC
Permalink
Post by Brian
Can anyone help, I'm using a ListView control from CommControl 6.0, when I
try to fill the listview using the code below, I get a Runtime error 380
Invalid Property Value when executing the first .SubItems line.
Any suggestions?
Sub tempList()
Dim lstStuff As MSComctlLib.ListItem
Dim count%
ListView1.ListItems.Clear
For count = 1 To 3
Set lstStuff = ListView1.ListItems.Add(, "X" & count, "One")
With ListView1
With lstStuff
.SubItems(1) = "Two" & count
.SubItems(2) = "Three" & count
Me thinks you need:

.ListSubItems.Add , , "Two" & count
.ListSubItems.Add , , "Three" & count



--
Björn Holmgren
Brian
2004-09-10 14:20:10 UTC
Permalink
Thanks Bjorn,

I no longer get the error, however, I don't get any values showing in the
ListView control, everything appears to work but the box remains empty, any
ideas?

What I'm trying to acheive is to fill the ListView with database records I
have just retrieved.

Brian
Post by Björn Holmgren
Post by Brian
Can anyone help, I'm using a ListView control from CommControl 6.0, when I
try to fill the listview using the code below, I get a Runtime error 380
Invalid Property Value when executing the first .SubItems line.
Any suggestions?
Sub tempList()
Dim lstStuff As MSComctlLib.ListItem
Dim count%
ListView1.ListItems.Clear
For count = 1 To 3
Set lstStuff = ListView1.ListItems.Add(, "X" & count, "One")
With ListView1
With lstStuff
.SubItems(1) = "Two" & count
.SubItems(2) = "Three" & count
.ListSubItems.Add , , "Two" & count
.ListSubItems.Add , , "Three" & count
--
Björn Holmgren
Jan Hyde
2004-09-10 14:19:28 UTC
Permalink
"Brian" <***@markem.com>'s wild thoughts were
released on Fri, 10 Sep 2004 09:05:18 -0400 bearing the
Post by Brian
Can anyone help, I'm using a ListView control from CommControl 6.0, when I
try to fill the listview using the code below, I get a Runtime error 380
Invalid Property Value when executing the first .SubItems line.
Any suggestions?
Sub tempList()
Dim lstStuff As MSComctlLib.ListItem
Dim count%
ListView1.ListItems.Clear
For count = 1 To 3
Set lstStuff = ListView1.ListItems.Add(, "X" & count, "One")
With ListView1
With lstStuff
.SubItems(1) = "Two" & count
.SubItems(2) = "Three" & count
End With
End With
Next count
End Sub
Thanks,
Brian
Sub tempList()
Dim lstStuff As MSComctlLib.ListItem
Dim intCount As Integer

With ListView1
.ListItems.Clear

.ColumnHeaders.Add , , "Col1"
.ColumnHeaders.Add , , "Col2"
.ColumnHeaders.Add , , "Col3"
End With
For intCount = 1 To 3
Set lstStuff = ListView1.ListItems.Add(, "X" &
intCount, "One")

With ListView1
With lstStuff
.SubItems(1) = "Two" & count
.SubItems(2) = "Three" & count
End With
End With
Next
End Sub


Jan Hyde (VB MVP)
--
Three o'clock is always too late or too early
for anything you want to do.

Jean-Paul Sartre

[Abolish the TV License - http://www.tvlicensing.biz/]
Brian
2004-09-10 14:31:37 UTC
Permalink
Thanks Jan,

That did the trick perfectly, much appreciated....

Brian
Post by Jan Hyde
released on Fri, 10 Sep 2004 09:05:18 -0400 bearing the
Post by Brian
Can anyone help, I'm using a ListView control from CommControl 6.0, when I
try to fill the listview using the code below, I get a Runtime error 380
Invalid Property Value when executing the first .SubItems line.
Any suggestions?
Sub tempList()
Dim lstStuff As MSComctlLib.ListItem
Dim count%
ListView1.ListItems.Clear
For count = 1 To 3
Set lstStuff = ListView1.ListItems.Add(, "X" & count, "One")
With ListView1
With lstStuff
.SubItems(1) = "Two" & count
.SubItems(2) = "Three" & count
End With
End With
Next count
End Sub
Thanks,
Brian
Sub tempList()
Dim lstStuff As MSComctlLib.ListItem
Dim intCount As Integer
With ListView1
.ListItems.Clear
.ColumnHeaders.Add , , "Col1"
.ColumnHeaders.Add , , "Col2"
.ColumnHeaders.Add , , "Col3"
End With
For intCount = 1 To 3
Set lstStuff = ListView1.ListItems.Add(, "X" &
intCount, "One")
With ListView1
With lstStuff
.SubItems(1) = "Two" & count
.SubItems(2) = "Three" & count
End With
End With
Next
End Sub
Jan Hyde (VB MVP)
--
Three o'clock is always too late or too early
for anything you want to do.
Jean-Paul Sartre
[Abolish the TV License - http://www.tvlicensing.biz/]
Larry Serflaten
2004-09-10 15:32:54 UTC
Permalink
Post by Brian
Thanks Jan,
That did the trick perfectly, much appreciated....
Post by Brian
With ListView1
With lstStuff
.SubItems(1) = "Two" & count
.SubItems(2) = "Three" & count
End With
End With
Of what use is the outer With block? Could you not remove it and
still get the expected results?

LFS
Jan Hyde
2004-09-13 09:12:47 UTC
Permalink
"Larry Serflaten" <***@usinternet.com>'s wild thoughts
were released on Fri, 10 Sep 2004 10:32:54 -0500 bearing the
Post by Larry Serflaten
Post by Brian
Thanks Jan,
That did the trick perfectly, much appreciated....
Post by Brian
With ListView1
With lstStuff
.SubItems(1) = "Two" & count
.SubItems(2) = "Three" & count
End With
End With
Of what use is the outer With block? Could you not remove it and
still get the expected results?
LFS
The outer one, yea. It is serving no purpose.



Jan Hyde (VB MVP)
--
Grammar: Lives with granpar (Jan Hyde)

[Abolish the TV License - http://www.tvlicensing.biz/]
Ken Halter
2004-09-10 14:30:23 UTC
Permalink
Post by Brian
With ListView1
The 'outer' With above doesn't do anything. lstStuff already has a
reference to ListView1 so you don't need the With ListView1 (it actually
may be causing a problem). The With below is all you should need.
Post by Brian
With lstStuff
.SubItems(1) = "Two" & count
.SubItems(2) = "Three" & count
End With
don't need the End With below either...
Post by Brian
End With
Since you're using the common controls 6 version, try something like.....
'==============================
Private Sub Form_Load()
Dim i As Integer
With ListView1
.View = lvwReport
.ColumnHeaders.Add , , "Item"
.ColumnHeaders.Add , , "SubItem1"
.ColumnHeaders.Add , , "SubItem2"
For i = 1 To 10
With .ListItems.Add 'add an item
.Text = "Item " & i

With .ListSubItems.Add 'add a subitem
.Text = "SubItem1 " & i
End With

With .ListSubItems.Add 'add a subitem
.Text = "SubItem2 " & i
End With

End With
Next
End With
End Sub
'==============================
--
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..
Continue reading on narkive:
Loading...