I need to retrieve my data from a ListView control set up in Details mode with 5 columns.
I tried using this code:
MessageBox.Show(ManageList.SelectedItems(0).Text)
And it works, but only for the first selected item (item 0). If I try this:
MessageBox.Show(ManageList.SelectedItems(2).Text)
I get this error:开发者_开发百科
InvalidArgument=Value of '2' is not valid for 'index'. Parameter name: index
I have no clue how I can fix this, any help?
Edit: Sorry, should have said, I'm using Windows.Forms :)
Right, from what I've tested:
Private Sub Button1Click(ByVal sender As Object, ByVal e As EventArgs)
For index As Integer = 0 To Me.listView1.SelectedItems.Count - 1
MessageBox.Show(Me.listView1.SelectedItems(index).Text)
Next
End Sub
(items added like this:)
For i As Integer = 0 To 99
Me.listView1.Items.Add(String.Format("test{0}", i))
Next
It just works.
So are you sure you have selected more than 1 item? Could you please show us more code? :)
精彩评论