How can the value of the SelectedItem on a ListView control can be refreshed?
Thank you,
Printable View
How can the value of the SelectedItem on a ListView control can be refreshed?
Thank you,
Do you mean:
Code:lvwList.SelectedItem.Text = "new text"
Hi Achichincle,
Thanks for replying. What I mean is I have a loop on how many records on a listview control. It checks if the listitem is selected or not. If it is selected, it gets the current value. However, when I am using this kind of code, it doesn't get the next value. It just gets the first value. Here's my sample program:
With ListViewMetrics.ListItems
For i = 1 To ListViewMetrics.ListItems.Count
If ListViewMetrics.ListItems.Item(i).Selected = True Then
'save the record in database
'MsgBox ListViewMetrics.SelectedItem.Text
sStratID = ListViewMetrics.SelectedItem.SubItems(2) 'Stratification Value
sMetID = ListViewMetrics.SelectedItem.SubItems(3) 'Metric ID
sDashID = ListViewMetrics.SelectedItem.SubItems(4) 'Dashboard ID
End If
Next i
End With
The value of sStratID, sMetID, sDashID is not refreshed with the new selected record in the listview control. What is wrong?
Thank you very much! :)
I gotcha.
Try:
The problem is that if you have more than one item selected in the listview it doesn't know which one you're referring to.Code:sStratID = ListViewMetrics.ListItems(i).SubItems(2) 'Stratification Value
sMetID = ListViewMetrics.ListItems(i).SubItems(3) 'Metric ID
sDashID = ListViewMetrics.ListItems(i).SubItems(4) 'Dashboard ID
I've also noticed that when you load items into a listview their .Selected property seems to be set to True eventhough they don't appear as selected on the listview display.
What I've done is explicitly set the .Selected property to False when I'm loading the listview items in order to avoid this problem.
Hope this helps...
Hi Achichincle!
Thank you so much because this works!!!
Have a nice day, :)