Solved

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

Posted on 2008-06-14
6
365 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
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
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 …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 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