We help IT Professionals succeed at work.

Creating multi-column listview and populating with data from access database

Petermcg001
Petermcg001 asked
on
2,658 Views
Last Modified: 2008-09-13
Hi,

I'd like to create a multi-column listview in VB.net to display the results of an ExecuteReader command.

I can get the first column to appear with the correct number of rows but I'm struggling to add the other columns to the view and populate them.  I'm probably missing something obvious but a simple step-by-step would be appreciated

Thanks
Comment
Watch Question

Jorge PaulinoIT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
If your problem is just the subitems you can do this way:

Dim item As ListViewItem

' Then on the loop
item = New ListViewItem
item.Text = "First column"
item.SubItems.Add("Second column")
item.SubItems.Add("Third column")

And in the columns you just have to add:
Me.ListView1.Columns.Add("ID", 50, HorizontalAlignment.Left)
Me.ListView1.Columns.Add("Column2", 50, HorizontalAlignment.Left)
Me.ListView1.Columns.Add("Column3", 50, HorizontalAlignment.Left)







CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.