05-21-2012, 03:34 PM
Hm, well, looking at your existing code.. I don't really know what you're doing. Sorry about that.
So, I wrote my own method which should do what you intended. I don't know if it's what you wanted, but you can take a look at it.
Pastebin version: <!-- m --><a class="postlink" href="http://pastebin.com/jhmyty3t">http://pastebin.com/jhmyty3t</a><!-- m -->
Just call this method every time the SelectedIndex is changed on the ListView control.
So, I wrote my own method which should do what you intended. I don't know if it's what you wanted, but you can take a look at it.
Code:
'This method colors all of the list view items according to the following data
'Selected items: backcolor = light green
'Unselected items: backcolor = white
'@param: the listview to be searched and colored
Public Sub RecolorListView(ByVal lstView As ListView)
'Scroll through each listview item
For Each item In lstView.Items
If lstView.SelectedItems.Contains(item) Then 'The item is selected
CType(item, ListViewItem).BackColor = Color.LightGreen 'Color it green!
Else 'The item is not selected
CType(item, ListViewItem).BackColor = Color.White 'Color it white
End If
Next
End Sub
Pastebin version: <!-- m --><a class="postlink" href="http://pastebin.com/jhmyty3t">http://pastebin.com/jhmyty3t</a><!-- m -->
Just call this method every time the SelectedIndex is changed on the ListView control.