DanS
12/31/2011 2:05:00 PM
BeeJ <nospam@spamnot.com> wrote in
news:jdim2r$t94$1@speranza.aioe.org:
> DanS brought next idea :
>> BeeJ <nospam@spamnot.com> wrote in
>> news:jdgcm0$ajk$1@speranza.aioe.org:
>>
>>> DanS explained on 12/28/2011 :
>>>> BeeJ <nospam@spamnot.com> wrote in
>>>> news:jdde7i$q0f$1@speranza.aioe.org:
>>>>
>>>>
>>>>> For lCol = 1 To LVW.ColumnHeaders.Count - 1
>>>>> ListViewRowGet = ListViewRowGet & sSep &
>>>>> LVW.ListItems(lRow).SubItems(lCol)
>>>>> If bSubTags Then
>>>>> ListViewRowGet = ListViewRowGet & sSep &
>>>>> LVW.ListItems(lRow).ListSubItems(lCol)
>>>>> .T ag
>>>>
>>>> Above I see...
>>>>
>>>> LVW.ListItems(lRow).SubItems(lCol)
>>>>
>>>> ....and also....
>>>>
>>>> LVW.ListItems(lRow).ListSubItems(lCol).Tag
>>>>
>>>>
>>>>
>>>> IIRC, .SubItems(lCol) is the Common Controls 5 version
>>>> hierarchy and .*List*SubItems(lCol) is the Common
>>>> Controls 6 callout.
>>>>
>>>> I'm guessing you are using v5 if the .SubItems(lCol)
>>>> line didn't error out.
>>>
>>> It is both VB6 and Common Controls 6. Both
>>> .SubItems(lCol) and .*List*SubItems(lCol) are accepted.
>>
>> I see that now.
>>
>> FWIW, I just created a test project populating a LV with
>> rows and columns using both .ListSubItems.Add, and using
>> .Subitem (x) = Text......
>>
>> ...and both ways, I could access the .tag property w/o
>> error, whether or not the tag was set to anyting.
>
> Strange. Did you not touch the SubItem?
> In my case I only touched the .Text, SubItem(1) and
> itmX.Tag (the row tag). DId not touch the SubItem(2) or
> ListSubItem(2).Tag.
In a new project, on a form I added a LV from CC ver6 (sp6),
set it to report view, and added 5 column headers.
The extent of the test code was:
Private Sub Command1_Click()
Dim x As Long
For x = 1 To 25
lv1.ListItems.Add , , "List-Item " & x
lv1.ListItems(x).SubItems(1) = "Sub-Item 1"
lv1.ListItems(x).SubItems(2) = "Sub-Item 2"
lv1.ListItems(x).SubItems(3) = "Sub-Item 3"
lv1.ListItems(x).SubItems(4) = "Sub-Item 4"
Next
End Sub
Private Sub Command2_Click()
If Not (lv1.SelectedItem Is Nothing) Then
lv1.SelectedItem.ListSubItems(2).Tag = Time$
Debug.Print "Item " & lv1.SelectedItem.Index & " tag
set to: " & Time$
End If
End Sub
Private Sub Command3_Click()
If Not (lv1.SelectedItem Is Nothing) Then
If Len(lv1.SelectedItem.ListSubItems(2).Tag) Then
Debug.Print "Item " & lv1.SelectedItem.Index & "
tag: " & lv1.SelectedItem.ListSubItems(2).Tag
Else
Debug.Print "Item " & lv1.SelectedItem.Index & "
has no tag"
End If
End If
End Sub
Button 1 to populate the LV.
Button 2 to set Sub-Item(2) tag of the selected item.
Button 3 to debug.print Sub-Item(2).tag of the selected item.