ListBox or ListView?

C

CR

In VB6 if I wanted to display a group of records, and possibly allow
the user to select one or more records, I would use the ListBox. For
example suppose I wanted to display something like this:

Name Address Phone Number
Johnson 111 South Av 111-1111
Smith 222 Main St 222-2222

In VB6 I would use a label and a listbox. The label would contain the
header. To make the columns line up in the listbox I would use a
"fixed length" font. Then I would pad each listbox entry with spaces
in between each field. It was easy to do but I'm wondering if there is
a better way in .NET.

Thanks!

Chuck.
 
J

Jeremy Cowles

CR said:
In VB6 I would use a label and a listbox. The label would contain the
header. To make the columns line up in the listbox I would use a
"fixed length" font. Then I would pad each listbox entry with spaces
in between each field. It was easy to do but I'm wondering if there is
a better way in .NET.

FYI, ListView was available in VB 6 as well, and has been around since
Windows95T. I personally always opt for the ListView over the list when I
am dealing with more than one column of data.

The [old] ListBox has a "Columns" property that would have lined the data up
for you, without using a fixed width font. The new one may have this same
property, but I haven't looked.


HTH,
Jeremy
 
H

Herfried K. Wagner [MVP]

* (e-mail address removed) (CR) scripsit:
In VB6 if I wanted to display a group of records, and possibly allow
the user to select one or more records, I would use the ListBox. For
example suppose I wanted to display something like this:

Name Address Phone Number
Johnson 111 South Av 111-1111
Smith 222 Main St 222-2222

In VB6 I would use a label and a listbox. The label would contain the
header. To make the columns line up in the listbox I would use a
"fixed length" font. Then I would pad each listbox entry with spaces
in between each field. It was easy to do but I'm wondering if there is
a better way in .NET.

.... a ListView with 'Columns' and 'View' = 'Details' (items + subitems).
 
S

solex

Jeremy,

From what I remember the of the ListBox the columns property allow the data
to wrap around so that you could sroll horizontally to see the list data and
could not be use to display data as the OP desires.

Dan

Jeremy Cowles said:
CR said:
In VB6 I would use a label and a listbox. The label would contain the
header. To make the columns line up in the listbox I would use a
"fixed length" font. Then I would pad each listbox entry with spaces
in between each field. It was easy to do but I'm wondering if there is
a better way in .NET.

FYI, ListView was available in VB 6 as well, and has been around since
Windows95T. I personally always opt for the ListView over the list when I
am dealing with more than one column of data.

The [old] ListBox has a "Columns" property that would have lined the data up
for you, without using a fixed width font. The new one may have this same
property, but I haven't looked.


HTH,
Jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top