Filling a list box from a table

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

VS2008. I have a table in an access database. How can I fill a list box with
a column from the table?

Thanks

Regards
 
John,

Just get the table in any way, if that is a datatable, then it is just
setting the datasource to the table, the displaymember to the columname (as
datable.Column.Columname or as string) and the same for the valuemember

To get the table you need OleDB.

It is so simple that there are probably no samples for this.

Cor
 
John,

Just get the table in any way, if that is a datatable, then it is just
setting the datasource to the table, the displaymember to the columname (as
datable.Column.Columname or as string) and the same for the valuemember

To get the table you need OleDB.

It is so simple that there are probably no samples for this.

Cor
If I can do a follow on from there.

If the table the data is coming from is a lookup table (say a unique
ID and a branch name), if I have branch name as the displaymember and
the unique id as the value member. How would I then go away saving
the value of the unique id to another table?

Don
 
myListBox.DataSource = MyTable
myListBox.DisplayMember = "BranchName"
myListBox.ValueMember = "MyIDName"

With a ; at the end in C#

TheOtherTable.Rows(TheRowRowNumber).Item("TheField") =
myListBox.SelectedValue
or in C#
TheOtherTable[TheRowNumber]["TheField"] = myListBox.SelectedValue;

Cor
 
Back
Top