Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

double click selected item in ListView to open a form vb.net 2003

Posted on 2006-10-29
3
Medium Priority
?
955 Views
Last Modified: 2008-01-09
Hi Experts,

I've created a FORM which has a BUTTON and a LISTVIEW.  When I click the button, it loads items from a text file into the Listview - . So far so good

column A   column B
data           data2
data           data2

The next step is that if an Item in a ROW is double clicked then I want it to open FORM2. When I inserted code into the Double-click button... I get a 'Select expression cannot be of type' error message. See below:
---------------------
Private Sub ListView4_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView4.DoubleClick
        Select Case ListView4.SelectedItems
            Case 0
                If frmTwo Is Nothing Then
                    frmTwo = New form
                End If
                frmTwo.Show()
        End Select
--------------------

Can anyone Help.
Cheers
0
Comment
Question by:RobertoFreemano
[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
3 Comments
 
LVL 14

Expert Comment

by:nayernaguib
ID: 17830245
Replace ListView4.SelectedItems with ListView4.SelectedIndices(0).

_______________

  Nayer Naguib
0
 
LVL 4

Accepted Solution

by:
mattcarver earned 60 total points
ID: 17834912
I wouldn't put "(0)" at the end since the Roberto is using a Select Case statement.  My assumption is he may want to expand this case statement in the future to support additional listview items.

Here is the corrected code:

-------------------------------------------  cut below here -------------------------------------------

Private Sub ListView4_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView4.DoubleClick
        Select Case ListView4.SelectedIndices
            Case 0
                If frmTwo Is Nothing Then
                    frmTwo = New form
                End If
                frmTwo.Show()
        End Select
0
 
LVL 14

Assisted Solution

by:nayernaguib
nayernaguib earned 90 total points
ID: 17835428
Actually this code will not even compile; you cannot compare a collection to an integer. Instead, the expression ListView4.SelectedIndices(0) refers to the index of the first selected item. If you need to iterate over all ListView items, you can put the Select block inside a For loop and replace ListView4.SelectedIndices(0) with ListView4.SelectedIndices(i).

_______________

  Nayer Naguib
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Starting up a Project

610 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