Populating ComboBox from Table

  • Thread starter Thread starter Lumpierbritches
  • Start date Start date
L

Lumpierbritches

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
 
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
 
Hi,

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

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

System.Data.DataViewManagerListItemTypeDescriptor
 
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
 
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.
 
Hi,

You probably have the column name wrong. Try this.

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

Ken
 
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
 
I did not see Ken today.
">
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")
cboBreed.DataSource = Breed1.tables("tblBreed")
cboBeed.displaymember= Breed1.tables("tblBreed").Columns(0)

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

This is almost as Ken wrote.

Cor
 
Back
Top