Bound Combo box

J

Jack

I have a form with a combo box that the items are being
sourced from a dataset.

The problem is that the list only get populated after the
form was previously opened; meaning, I open the form with
the combo and the list is empty, then I close it and open
it again and now it has data in the list.

The code that executes when the form is loaded is below:

CampaignSelectForm.DsCampaign1.Clear()
CDsCampaign1.Clear()
OleDbDataAdapter1.Fill(DsCampaign1)
Combo1.DataSource = DsCampaign1.campaign
Combo1.DisplayMember=DsCampaign1.campaign.campaignColumn.To
String
Combo1.Refresh()
 
J

jack

The two clears were a typo (actually a cut and paste-o),
it is not in the code that way.

The row count of the underlying table is three (3) and
three items show up when the form is closed and reloaded.

Output form the Immediate Window:
?DsCampaign1.Tables.Item("campaign").Rows
{System.Data.DataRowCollection}
Count: 3
IsReadOnly: False
IsSynchronized: False
Item: <cannot view indexed property>
SyncRoot: {System.Data.DataRowCollection}
?DsCampaign1.Tables.Item("campaign").Rows.Count
3

Jack
 
G

Guest

Additional Info:
When I walk through the code Combo1.DataSource always is
nothing on the first load. Even after the call to:
Combo1.DataSource = DsCampaign1.campaign
and after I try to manuall assign it to the datatable via
any of the ways:
DsCampaign1.tablecampaign
DsCampaign1.Tables("Campaign")

I can also look at in the immed window and it has data.
 
J

Jack

Problem solved.

It must have had to do with the migration of the control.
I deleted the control and re-added it and not it works
fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top