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 / .NET Framework / ADO.NET / January 2006

Tip: Looking for answers? Try searching our database.

custom field in DataTable for listbox binding

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
wesbird - 09 Jan 2006 19:05 GMT
Hi:
 I have a dialog in WinForm with 2 list box, source and destination, and 4
buttons, add, add all, remove and remove all. So user can add single/all
items in source list box to destination one. so as remove and remove all
buttons. I binding a DataTable to source and destination list box. Now my
problem is, in my DataTable, there are fields ID, FirstName, LastName. I like
to show full name in the list box.
 What should I do?
Jesús López - 09 Jan 2006 20:05 GMT
The ListBox control cannot show more than one field at a time, so I suggest
you adding a new calculated field to the datatable witih LastName and
FirstName concatenated. Something like this:

       SourceTable.Columns.Add("FullName", GetType(String), "LastName + ',
' + FirstName")
       Me.ListBox1.DataSource = SourceTable
       Me.ListBox1.DisplayMember = "FullName"
       Me.ListBox1.ValueMember = "ID"

Regards from Madrid (Spain)

Jesús López
VB MVP

> Hi:
>  I have a dialog in WinForm with 2 list box, source and destination, and 4
[quoted text clipped - 5 lines]
> to show full name in the list box.
>  What should I do?
William (Bill) Vaughn - 09 Jan 2006 23:42 GMT
Write your SELECT to do the concatenation:
   SELECT FirstName + " " + LastName AS [Name] FROM ...

Signature

____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
INETA Speaker
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

> Hi:
>  I have a dialog in WinForm with 2 list box, source and destination, and 4
[quoted text clipped - 5 lines]
> to show full name in the list box.
>  What should I do?
Cor Ligthert [MVP] - 10 Jan 2006 09:20 GMT
wesbird,

> Write your SELECT to do the concatenation:
>    SELECT FirstName + " " + LastName AS [Name] FROM ...

Juan and Bill give you the in my opinion two nicest alternatives (it is just
what you prefer).

Probably do you need for the combobox value as well the ID, in the select
from Bill.

Just as very slight addition to Bills string

:-)

Cor

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.