all groups > vb.net controls > july 2005 >
You're in the

vb.net controls

group:

ListView


ListView Lou
7/19/2005 5:56:18 PM
vb.net controls:
How do I get the first selected item of a listview
here is what I've tried but it crashes on the item= part.
i do have items in the list view and i do have 1 item selected

Dim item As ListViewItem

item = lvMyStuff.SelectedItems(0)

Debug.WriteLine(item.SubItems(2).Text)

-Lou

Re: ListView Mona
7/21/2005 12:00:00 AM
Hi Lou,

After selecting 1 item in the list view that contained sub-items, I used =
the following code and this is working fine:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As =
System.EventArgs) Handles Button1.Click
Dim item As ListViewItem

item =3D Me.ListView1.SelectedItems(0)

Debug.WriteLine(item.SubItems(2).Text)

End Sub

Make sure that the sub-item of your main item also exists. Can you also =
post the error message that you are getting.

Thanks

Mona [GrapeCity]

[quoted text, click to view]
AddThis Social Bookmark Button