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
Kerry Moorman - 31 Jul 2007 16:00 GMT
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
> i need to display 2 columns of data in a list box.
>
[quoted text clipped - 16 lines]
>
> ray
Cor Ligthert[MVP] - 31 Jul 2007 16:05 GMT
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
>i need to display 2 columns of data in a list box.
>
[quoted text clipped - 16 lines]
>
> ray