HighTechTalks DotNet Forums  

Filling a list box from a table

Dotnet Framework (ADO.net) microsoft.public.dotnet.framework.adonet


Discuss Filling a list box from a table in the Dotnet Framework (ADO.net) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
John
 
Posts: n/a

Default Filling a list box from a table - 12-30-2007 , 09:48 PM






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



Reply With Quote
  #2  
Old   
Cor Ligthert[MVP]
 
Posts: n/a

Default Re: Filling a list box from a table - 12-31-2007 , 04:06 AM






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


Reply With Quote
  #3  
Old   
dgcarter@hotmail.com
 
Posts: n/a

Default Re: Filling a list box from a table - 01-01-2008 , 10:50 AM



On Mon, 31 Dec 2007 11:06:16 +0100, "Cor Ligthert[MVP]"
<notmyfirstname (AT) planet (DOT) nl> wrote:

Quote:
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


Reply With Quote
  #4  
Old   
Cor Ligthert[MVP]
 
Posts: n/a

Default Re: Filling a list box from a table - 01-01-2008 , 11:02 AM



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

<dgcarter (AT) hotmail (DOT) com> schreef in bericht
news:mnrkn351blqjlsci3evhksep8siaq5n3ul (AT) 4ax (DOT) com...
Quote:
On Mon, 31 Dec 2007 11:06:16 +0100, "Cor Ligthert[MVP]"
notmyfirstname (AT) planet (DOT) nl> wrote:

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


Reply With Quote
  #5  
Old   
dgcarter1949@googlemail.com
 
Posts: n/a

Default Re: Filling a list box from a table - 01-02-2008 , 03:25 PM



On 1 Jan, 17:02, "Cor Ligthert[MVP]" <notmyfirstn... (AT) planet (DOT) nl> wrote:
Quote:
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

dgcar... (AT) hotmail (DOT) com> schreef in berichtnews:mnrkn351blqjlsci3evhksep8siaq5n3ul (AT) 4ax (DOT) com...



On Mon, 31 Dec 2007 11:06:16 +0100, "Cor Ligthert[MVP]"
notmyfirstn... (AT) planet (DOT) nl> wrote:

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- Hide quoted text -

- Show quoted text -
Thanks Cor,

I'll give that a try.

Don


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.