[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 335
  • Last Modified:

VB.net ListView can only select first column

Hi

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)
        Try
            Dim sSQL As String = "SELECT * FROM [Rooms] Where Number = " & CStr(oRoomNumber)

            Me.ListView_Rooms.BeginUpdate()
            Using myConnection As New OleDbConnection(ConnectionString)
                Dim myCommand As New OleDbCommand(sSQL, myConnection)
                myConnection.Open()
                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())
                        myItem.SubItems.Add(dr("Description").ToString())
                        myItem.SubItems.Add(dr("Detail").ToString())
                    Loop
                End Using
            End Using
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            Me.ListView_Rooms.EndUpdate()
        End Try
    End Sub

Open in new window

0
Murray Brown
Asked:
Murray Brown
1 Solution
 
CodeCruiserCommented:
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks. Hadn't done that
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now