Solved

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

Posted on 2008-06-14
6
358 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
Comment Utility
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
Comment Utility
There is no .SelectedItems in PocketPC Version.
0
 
LVL 7

Expert Comment

by:garethh86
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:KenTan85
Comment Utility
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
Comment Utility
listview.selectedindices is getting the index of the item or wat???
0
 
LVL 7

Accepted Solution

by:
garethh86 earned 500 total points
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now