Populate a ListBox.Datasource with a Dataset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I want to populate a ListBox.Datasource with the results from my Dataset

What I have so far is my dataset
dataset.Tables("dataSetName") and that equates to say 4 fields (last name, first name, mid, i.d.

I know I can populate a datagrid, but, I'd like to do the same in a list box. So, I did the following
listBoxName.datasource = dataset.tables("DataSetName")

Which produces "system.dat.datarowview" for each row in the dataset..

Any advice on populating the listbox with "real" data

Thanks in advance

mar
 
Mark:

Have you set the DisplayMember and ValueMember properties? You should be
good to go then...
mark said:
Hi,

I want to populate a ListBox.Datasource with the results from my Dataset.

What I have so far is my dataset:
dataset.Tables("dataSetName") and that equates to say 4 fields (last name, first name, mid, i.d.)

I know I can populate a datagrid, but, I'd like to do the same in a list
box. So, I did the following:
 
Create an expression column that concatenates whatever fields you want to
display...I have an example of this at the beginning of this article
http://www.knowdotnet.com/articles/dataviews1.html

By Default a ListBox is only going to show one field, but if you create an
expression column, concatenate and format all of the fields you want to be
visible, then set the DisplayMember to the Expression Column, set the
Valuemember to whatever field you want SelectedValue to equal, you'll be
good to go.

Cheers,

Bill
 
Back
Top