By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,036 Members | 960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,036 IT Pros & Developers. It's quick & easy.

listbox with multiple columns

P: n/a
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
Jul 31 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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 well" wrote:
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
Jul 31 '07 #2

P: n/a
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

"ray well" <no****@nospam.comschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
>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

Jul 31 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.