Solved

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

Posted on 2008-06-14
6
363 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

763 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