How to get the value or index of a selected ListView???

I am working in Visual Studio 2005 PocketPc VB.NET, currently I had a ListView control, how do I get the user selected item value or index???
KenTan85Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
garethh86Connect With a Mentor Commented:
Hmmm, this seems a bit of a round about way of getting it but tested and works. Why wouldn't they include selecteditems in the compact framework!


Private Function listview1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) As privatevoid 
    For x As Integer = 0 To listview1.Items.Count - 1 
        
        
        If listview1.Items(x).Selected Then 
            MessageBox.Show(listview1.Items(x).SubItems(1).Text) 
        End If 
    Next 
    
End Function 

Open in new window

0
 
garethh86Commented:
Code below, assign it to a button click or repost when the user selects an item.

Hope this helps!
Dim UserSelectedItem = ListView1.SelectedItems
Label1.Text = UserSelectedItem

Open in new window

0
 
KenTan85Author Commented:
There is no .SelectedItems in PocketPC Version.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
garethh86Commented:
Sorry, seems your correct there, never really played around with PPC dev, you would imagine it was the same code wise. Try this:

listview.selectedindices

http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.selectedindices(VS.80).aspx

Hope this helps!
0
 
KenTan85Author Commented:
Do not quite understand the way the he used selectindices, could you kindly explain a little n if possible with a little code sample, that would be well.
0
 
KenTan85Author Commented:
listview.selectedindices is getting the index of the item or wat???
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.