Hi,
I am using vb.net 2005 and have a Windows Form with two ListViews; The ListViews are diplayed on the
Design surface, but I am progmatically adding the items to each ListView.
When adding the items to the list view I am iterating through and
setting the following:
I can retrieve the .ToolTipText and .Text values from then
SelectedListViewItemCollection but the .tag property is always empty (it
knows the object type is GUID but does not have the value). I know the
value is being set as I can set the ToolTipText to same ID as the TAG
and it is stored correctly.
Any ideas?
Many thanks in advance
I am using vb.net 2005 and have a Windows Form with two ListViews; The ListViews are diplayed on the
Design surface, but I am progmatically adding the items to each ListView.
When adding the items to the list view I am iterating through and
setting the following:
VB.NET:
...
With myListViewItem
.Text = drArticles("Title").ToString
.ToolTipText = drArticles("Summary").tostring
.Tag = CType(drArticles("ID"),Guid)
End With
myListView.Items.Add
... [/VBCODE]
The items are populated and dispalyed correctly in the ListView.
The problem arises when I respond to a SelectedIndexChanged, I get a reference to the selected item using:
[VBCODE] Dim mySelectedLVIC As System.Windows.Forms.ListView.SelectedListViewItemCollection
mySelectedLVIC = ListView2.SelectedItems()
If mySelectedLVIC .Count > 0 Then
Dim myLvi As ListViewItem
myLvi = mySelectedLVIC (0)
Dim myLviSelectedIndex As Guid
myLviSelectedIndex = CType(myLvi .Tag, Guid)
DisplayArticle(myLviSelectedIndex )
End If
I can retrieve the .ToolTipText and .Text values from then
SelectedListViewItemCollection but the .tag property is always empty (it
knows the object type is GUID but does not have the value). I know the
value is being set as I can set the ToolTipText to same ID as the TAG
and it is stored correctly.
Any ideas?
Many thanks in advance