Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / July 2007

Tip: Looking for answers? Try searching our database.

listbox with multiple columns

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ray well - 31 Jul 2007 14:24 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.