|
-
Jul 2nd, 2002, 05:18 AM
#1
Thread Starter
Frenzied Member
SubItems Count?
Yep, thats what i want. I want a function that tells if there is data
in SubItems(3). I know that there is nothing there, because when
i try to say lvw1.ListItems(i).SubItems(3) it gives an error.. it
dosen't exist, apparently, although on some OTHER rows it
exists. I need to be able to find out how many collums there are
on a specific row. Help !
-
Jul 2nd, 2002, 05:24 AM
#2
Frenzied Member
Try this:
VB Code:
ListView1.ListItems(i).ListSubItems.Count
oh1mie/Vic

-
Jul 2nd, 2002, 05:38 AM
#3
SAS Data-warehouse training...
It is good coding practice to use ListSubItems rather than SubItems.
I think, if I am not mistaken, that SubItems were there for old OS's and earlier versions of VB. These were left in so older programs would still work. ListSubItems were added to replace subitems...They have more properties: Colors, Fonts, Icons etc.
If you use ListSubItems instead of SubItems then you can do what oh1me suggested...ListView1.ListItems(n).ListSubItems.COunt...
Adios,
Woka
-
Jul 2nd, 2002, 05:50 AM
#4
Thread Starter
Frenzied Member
Ah! Thanks! I'll try this out when my gf stops bitching on the
phone!
Have a good one!
-
Jul 2nd, 2002, 06:25 AM
#5
Thread Starter
Frenzied Member
It dosent work. It always returns 3, even though there ISNT a
3rd colum with data in it.
-
Jul 2nd, 2002, 06:35 AM
#6
Add a listview to your form called ListView1, then:
VB Code:
Private Sub Form_Load()
Dim lvwItem As ListItem
With ListView1
.View = lvwReport
.ColumnHeaders.Add , , "WOOF"
.ColumnHeaders.Add , , "Hello"
.ColumnHeaders.Add , , "Column2"
.ColumnHeaders.Add , , "Muppet"
End With
Set lvwItem = ListView1.ListItems.Add(, , "Hello")
MsgBox lvwItem.ListSubItems.Count 'Returns 0
lvwItem.ListSubItems.Add , , "Data1"
MsgBox lvwItem.ListSubItems.Count 'Returns 1
End Sub
Returns how many listsubitems you have added....it works...
-
Jul 2nd, 2002, 08:12 AM
#7
Thread Starter
Frenzied Member
Heres the code i'm using.
VB Code:
For i = 1 To lstMP3s.ListCount - 1 Step 1
'lstMP3s.ListIndex = i
x.Filename = lstMP3s.List(i)
DoEvents
If cboSearchType.Text = "Artist" Then
If lvwMP3s.ListItems(lvwMP3s.ListItems.Count).Text = x.Artist And lvwMP3s.ListItems(lvwMP3s.ListItems.Count).ListSubItems(1) = x.Title And lvwMP3s.ListItems(lvwMP3s.ListItems.Count).ListSubItems(2) = x.Album And lvwMP3s.ListItems(lvwMP3s.ListItems.Count).ListSubItems(3) = x.Filename Then
lvwMP3s.ListItems.Remove lvwMP3s.ListItems.Count
y = y - 1
End If
If InStr(1, UCase(x.Artist), UCase(txtSearch.Text)) <> 0 Then
y = y + 1
If lvwMP3s.ListItems(1).Text = "Searching..." Then
lvwMP3s.Checkboxes = True
lvwMP3s.ListItems.Clear
End If
lvwMP3s.ListItems.Add , , x.Artist
lvwMP3s.ListItems(y).SubItems(1) = x.Title
lvwMP3s.ListItems(y).SubItems(2) = x.Album
lvwMP3s.ListItems(y).SubItems(3) = x.Filename
End If
End If
It dosen't work though. Sometimes it posts the same result
exactly except for ONE minor difference, the last field, which is
filename, is entirely empty. I tried lvwMP3s.ListIte
(y).ListSubItems.Count but it didn't work. I also tried
lvwMP3s.ListItems(y).SubItems(3) and it didn't work. Can
someone help me patch up this code so it removes the entry in
the listview if there is NOTHING in the last field ( 3 )?
-
Jul 2nd, 2002, 08:26 AM
#8
Thread Starter
Frenzied Member
I fixed it. After it's done adding the items, it does this
VB Code:
On Error Resume Next
For i = 1 To lvwMP3s.ListItems.Count - 1
If lvwMP3s.ListItems(i).SubItems(3) = "" Then lvwMP3s.ListItems.Remove i
Next i
Which works a charm for me! Thanks for all your replies!
-
Jul 2nd, 2002, 08:40 AM
#9
Glad it works, but you are still using SubItems...???
Use ListSubItems instead...far better...
Woka
-
Jul 2nd, 2002, 09:03 AM
#10
Thread Starter
Frenzied Member
Is it possible to use both SubItems and ListSubItems in
conjunction wiht one another? It would be a real pain if i ahd to
convert the whole thing to ListSubItems. And i'd be afraid to. The
code in this program is very delicate. Much more delicate than
one would think.
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
|