Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ListView not loading properly

Posted on 2011-10-15
7
Medium Priority
?
204 Views
Last Modified: 2012-05-12
Hi

I am using the following code to load a ListView.
Only the first record "Number" seems to be loading correctly
 ListView
even though my data looks as follows

Sub Fill_Rooms_ListView()
        Try
            Me.ListView_Rooms.Items.Clear()
            Me.ListView_Rooms.BeginUpdate()
            Using myConnection As New OleDbConnection(ConnectionString)
                Dim myCommand As New OleDbCommand("SELECT * FROM [Rooms]", 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())
                    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

image2.jpg
0
Comment
Question by:Murray Brown
  • 5
  • 2
7 Comments
 
LVL 17

Expert Comment

by:Carlos Villegas
ID: 36973857
Hello, set the View property of your ListView to Details, example:
Me.ListView_Rooms.View = System.Windows.Forms.View.Details

Open in new window

0
 
LVL 17

Expert Comment

by:Carlos Villegas
ID: 36973866
From the designer, example:
 Example
0
 

Author Comment

by:Murray Brown
ID: 36973871
That still doesn't work.
I get  the following

        image
0
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!

 
LVL 17

Accepted Solution

by:
Carlos Villegas earned 2000 total points
ID: 36973874
And don't forget define your columns too:
 Example
0
 
LVL 17

Expert Comment

by:Carlos Villegas
ID: 36973894
You will need 4 columns instead of 3
0
 

Author Closing Comment

by:Murray Brown
ID: 36973929
thanks very much
0
 
LVL 17

Expert Comment

by:Carlos Villegas
ID: 36973994
Glad to help
0

Featured Post

Independent Software Vendors: 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

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…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month21 days, 6 hours left to enroll

810 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