listbox with multiple columns

  • Thread starter Thread starter ray well
  • Start date Start date
R

ray well

i need to display 2 columns of data in a list box.

how would i set this up IN CODE.

say my table is tblNames, and i have 2 fields, FirstName, LastName, and want
the data to show up in 2 columns, LastName, followed by FirstName

normally i would say

ListBox1.DataSource = DataSet1.Tables("tblNames")
ListBox1.DisplayMember = "LastName"

but i want to define 2 columns in the list box with specified widths, and
then load the 2 fields.

how would i do that IN CODE?

thanks,

ray
 
Ray,

The Listbox control does not support multiple columns in the way that you
want to use them.

You could use a control that does support this type of multiple columns,
like a grid or listview.

Or you could create a "FullName" column in your datatable by combining
lastname, a comma, and firstname. Then use this "FullName" column as the
DisplayMember of the listbox.

Kerry Moorman
 
Ray,

You can create an extra column in your datatable which contains the
concatenated FirstName and the LastName or you can do it in your SQL querry.
Both are in my idea the most given answers for your question.

Cor
 
Back
Top