?
Solved

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

Posted on 2008-06-14
6
Medium Priority
?
366 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

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 2000 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

Major Serverless Shift

Comparison of major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

752 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