How to add table fields into list box

  • Thread starter Thread starter Alan
  • Start date Start date
A

Alan

I have a DataTable and would like to display all fields into the list box by
using:
CustomerName, CustomerPhone, CustomerAddress

lstResult.datasource = dt
lstResult.DisplayMember = .....

How do I assign the DisplayMember string ?
 
Hi,

You can only display one field in a listbox. Add a new datacolumn
to the datatable and show that field in the listbox.

Dim dc As DataColumn

dc = New DataColumn("Summary")

dc.DataType = System.Type.GetType("System.String")

dc.Expression = "CustomerName + ' ' + CustomerPhone + ' ' +
CustomerAddress"

dt.Columns.Add(dc)

dc = Nothing

lstResult.datasource = dt

lstResult.DisplayMember = "Summary"

Ken
 
Back
Top