Connecting Tech Pros Worldwide Forums | Help | Site Map

Populating ComboBox from Table

Lumpierbritches
Guest
 
Posts: n/a
#1: Nov 20 '05
thank you in advance for any and all assistance.

I'm trying to populate a combobox with a table in VB.Net.

Table Name: tblBreed
cboBreed

Thank you again.

Michael

Cor
Guest
 
Posts: n/a
#2: Nov 20 '05

re: Populating ComboBox from Table


Hi Micheal,

I think you get a lot of answers, because this is simple in vb.net

cbobreed.datasource = tblBreed
cbobreed.displaymember = "MyTableText"
cbobreed.valuemember = "Mytablevalue"

I hope this helps?

Cor


Ken Tucker [MVP]
Guest
 
Posts: n/a
#3: Nov 20 '05

re: Populating ComboBox from Table


Hi,

cboBreed.DataSource=tblBreed
cboBreed.DisplayMember = "FieldNameToDisplay"

Ken
--------------
"Lumpierbritches" <lumpierbritches@aol.com> wrote in message
news:20040304092658.20558.00000761@mb-m28.aol.com...[color=blue]
> thank you in advance for any and all assistance.
>
> I'm trying to populate a combobox with a table in VB.Net.
>
> Table Name: tblBreed
> cboBreed
>
> Thank you again.
>
> Michael[/color]


Lumpierbritches
Guest
 
Posts: n/a
#4: Nov 20 '05

re: Populating ComboBox from Table


I get this when I put this in the Form Load Event:

System.Data.DataViewManagerListItemTypeDescriptor
Cor
Guest
 
Posts: n/a
#5: Nov 20 '05

re: Populating ComboBox from Table


Hi Lumpier.....

cbobreed.displaymember = "MyTableText"
cbobreed.valuemember = "Mytablevalue"

Did you use that "MyTableText" or the name from the column in your table (or
said in another way, the column (item) name in the database)?

(It has to be between quotes)

The valuemember is not necessary if you do not use it.

I hope that it will work now?

Cor


Lumpierbritches
Guest
 
Posts: n/a
#6: Nov 20 '05

re: Populating ComboBox from Table


I'm too dense to understand. I've tried in the cboBreed event change, and in
the formload event to load the values in table breed into my combo box and all
I get is

System.Data.DataViewManagerListItemTypeDescriptor

HELP!!! I'm gettting so frustrated. In VB6, there was a data combobox that
allowed for data porting to the combobox and a wizard for idiots like me.
Ken Tucker [MVP]
Guest
 
Posts: n/a
#7: Nov 20 '05

re: Populating ComboBox from Table


Hi,

You probably have the column name wrong. Try this.

cboBreed.DataSource=tblBreed
cboBreed.DisplayMember = tblBreed.Columns(0).ColumnName

Ken
------------------
"Lumpierbritches" <lumpierbritches@aol.com> wrote in message
news:20040304163805.06601.00000796@mb-m25.aol.com...[color=blue]
> I'm too dense to understand. I've tried in the cboBreed event change, and[/color]
in[color=blue]
> the formload event to load the values in table breed into my combo box and[/color]
all[color=blue]
> I get is
>
> System.Data.DataViewManagerListItemTypeDescriptor
>
> HELP!!! I'm gettting so frustrated. In VB6, there was a data combobox that
> allowed for data porting to the combobox and a wizard for idiots like me.[/color]


Lumpierbritches
Guest
 
Posts: n/a
#8: Nov 20 '05

re: Populating ComboBox from Table


Ken,

Thank you for your assistance. I can get the first, "selected" value, but I
still can't populate the combobox with the values in the table. Here is my
complete code:

Private Sub frmAnimal_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
AnimalDA.Fill(Animal1, "tblAnimal")
BreedDA.Fill(Breed1, "tblBreed")
End Sub

Private Sub cboBreed_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cboBreed.SelectedIndexChanged
cboBreed.DataSource = Breed1.tblBreed.Columns(0)
End Sub
Cor
Guest
 
Posts: n/a
#9: Nov 20 '05

re: Populating ComboBox from Table


I did not see Ken today.
">[color=blue]
> Private Sub frmAnimal_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> AnimalDA.Fill(Animal1, "tblAnimal")
> BreedDA.Fill(Breed1, "tblBreed")[/color]
cboBreed.DataSource = Breed1.tables("tblBreed")
cboBeed.displaymember= Breed1.tables("tblBreed").Columns(0)[color=blue]
> End Sub[/color]

I asume you did the rest using the designer (wizards)

This is almost as Ken wrote.

Cor


Closed Thread