By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,068 Members | 867 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,068 IT Pros & Developers. It's quick & easy.

Setting ListView.SubItem(x).Text

P: n/a
Hi all,

I made an overview of all my contacts. This overview is shown in a ListView.
I programmatically add as many columns as there are in my contacts database
table. All the contacts and their information are shown nicely.
When I doubleclick an item I show a window in which the user can alter any
of the data for teh selected contact. After clicking the OK-button I change
the database and then try to set the text property of all the subitems of
the selected contact. None of the alterations are displayed. When displaying
the subitem in the QuickWatch window, the Text property is correctly set to
the new value. Any idea what I'm doing wrong here?
Here's my code:

Private Sub LV_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles LV.DoubleClick
If LV.SelectedItems.Count = 0 Then
Exit Sub
End If
Dim f2 As New Form2()
Dim Rst As New ADODB.Recordset()
Dim SelLVI As ListViewItem = LV.SelectedItems(0)
With f2
Rst.Open("SELECT * FROM Adressen WHERE pk = " & CType(SelLVI.Tag,
String), Con, ADODB.CursorTypeEnum.adOpenKeyset,
If Not IsDBNull(Rst.Fields("Naam").Value) Then
.txtNaam.Text = CType(Rst.Fields("Naam").Value, String)
End If
If Not IsDBNull(Rst.Fields("Adres").Value) Then
.txtAdres.Text = CType(Rst.Fields("Adres").Value, String)
End If
.bChanged = False
If .bOK Then
If .bChanged Then
Rst.Fields("Naam").Value = .txtNaam.Text
Rst.Fields("Adres").Value = .txtAdres.Text
SelLVI.Text = .txtNaam.Text 'This is displayed correctly
SelLVI.SubItems(1).Text = .txtAdres.Text 'This is NOT displayed
End If
End If
End With
End Sub
Thanks in advance,
Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Thanks for replying.
Unfortunately refreshing the listview does not work.

"purushotham bc" <bc******> wrote in message
Use the public method Refresh of Listview to see the

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.