?
Solved

VB.Net 2005 Listview Selected Values

Posted on 2007-03-28
5
Medium Priority
?
2,574 Views
Last Modified: 2008-01-09
Hi all,
I have a listview in a Windows form.  I want the user to be able to select a row and for me to be able to get the value(s) from that row when they have double clicked it.
Thanks.
0
Comment
Question by:porter416
[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
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:emailrobertwalker
ID: 18812159
To return the value of an Item try this.

Private Sub ListView1_DblClick()
    With ListView1
        MsgBox ListView1.SelectedItem
    End With
End Sub
0
 
LVL 3

Assisted Solution

by:emailrobertwalker
emailrobertwalker earned 200 total points
ID: 18812241
Here is the exact code for you ...

Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick
        Dim I As Integer
        For I = 0 To ListView1.SelectedItems.Count - 1
            MsgBox(ListView1.SelectedItems(I).Text)
        Next
End Sub
0
 

Author Comment

by:porter416
ID: 18812315
Wow.  Thanks for the quick response.  I should have added however, that the view has 3 columns and while I want the user to be able to select the row only, I need the values from the entire row.  How do I do this?  Your code returns the value from the first column only even when i click on the values in the third column.

Thanks again,
D.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 800 total points
ID: 18812902
   Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick
        If ListView1.SelectedItems.Count > 0 Then
            Dim lvi As ListViewItem = ListView1.SelectedItems(0)
            ' the first item listed is the item in column1...even though it is not a "subitem"
            For Each subItem As ListViewItem.ListViewSubItem In lvi.SubItems
                Debug.Print(subItem.Text)
            Next
        End If
    End Sub
0
 

Author Comment

by:porter416
ID: 18816802
Appreciate all your help from both of you.
D.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Suggested Courses

777 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