• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 547
  • Last Modified:

Multi column list control – the best choice

Hello

I’ve just started programming in VB.Net in Visual Studio having done lots of VBA.

I’d like to display a multi column list on my form.  I’d like to display files and their attributes:

Filename                             Album          Artist                     Track number
Nine Lives – Crash.mp3       Nine Lives          Aerosmith              3

Which is the best control to do this?

A ListBox appears to be able to store only one field of data – MultiColumn seems to mean displaying a single field of data down then across – with no vertical scroll bars, only horizontal

A ListView seems to be the best option.  I can populate it, but I can’t seem to “get” any values from it.  I can get the selected index number, but not the values.

Any pointers would be appreciated.

Thanks
0
IainTheVBALearner
Asked:
IainTheVBALearner
  • 2
1 Solution
 
jobrienctCommented:
Datagrid would probably be most appropriate for this.

heres a tutorial, have a look.

http://www.codeproject.com/vb/net/grid101.asp

John
0
 
jobrienctCommented:
If you want to use a listview then heres a snippet to get you started reading values:

   For Each row As ListViewItem In myListView.Items
      For Each column As ListViewItem.ListViewSubItem In row.SubItems
         MsgBox(column.Text)
     Next column
  Next row

In this way you can see the relationship between a listview and a coordinate grid or spreadsheet where it can behave as rows and columns and your values are the intersection.

JOhn
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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