Solved

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

Posted on 2008-06-14
6
360 Views
Last Modified: 2013-11-26
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???
0
Comment
Question by:KenTan85
  • 3
  • 3
6 Comments
 
LVL 7

Expert Comment

by:garethh86
ID: 21786267
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
 

Author Comment

by:KenTan85
ID: 21787339
There is no .SelectedItems in PocketPC Version.
0
 
LVL 7

Expert Comment

by:garethh86
ID: 21789236
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:KenTan85
ID: 21790495
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
 

Author Comment

by:KenTan85
ID: 21790507
listview.selectedindices is getting the index of the item or wat???
0
 
LVL 7

Accepted Solution

by:
garethh86 earned 500 total points
ID: 21791750
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

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now