Solved ListView can only select first column

Posted on 2011-10-15
Last Modified: 2012-05-12

I have a ListView control that I add rows to with the code below.
When I try to select a row, I am only able to do so by clicking on column 1
Is there a way to change this so that if the user clicks on any of
the other columns then that row will be selected.
Sub Add_Room_to_ListView(ByVal oRoomNumber As Integer)
            Dim sSQL As String = "SELECT * FROM [Rooms] Where Number = " & CStr(oRoomNumber)

            Using myConnection As New OleDbConnection(ConnectionString)
                Dim myCommand As New OleDbCommand(sSQL, myConnection)
                Using dr As OleDbDataReader = myCommand.ExecuteReader
                    Do While dr.Read
                        Dim myItem As ListViewItem = Me.ListView_Rooms.Items.Add(dr("Number").ToString())
                        myItem.SubItems.Add(dr("Rate Single").ToString())
                        myItem.SubItems.Add(dr("Rate Double").ToString())
                End Using
            End Using
        Catch ex As Exception
        End Try
    End Sub

Open in new window

Question by:murbro
    LVL 83

    Accepted Solution


    Author Closing Comment

    Thanks. Hadn't done that

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 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

    18 Experts available now in Live!

    Get 1:1 Help Now