newbie Problem with ComboBox

K

KentL

I have a CMMS application that I wrote in Access. I am trying to create the
same application using vb.net. I have a Work Order form where work orders
are created then completed. I have everything working properly with the
exception of some combo boxes. I can't seem to see any data in the first
combo box that I am trying to set up.

I have the following code in the form declarations
Public Class frmWorkOrdersInherits System.Windows.Forms.Form

Dim WO_HeadersBindingManager As BindingManagerBase

Dim ProjectNumbersBindingManager As BindingManagerBase



In the Load event I have;

daCMMS.Fill(DsWO_Headers)

daCMMS.Fill(dsProjectNumbers)

WO_HeadersBindingManager = Me.BindingContext(DsWO_Headers, "tblWO_Headers")

ProjectNumbersBindingManager = Me.BindingContext(dsProjectNumbers,
"tblApprovedProjects")

In the Data Adaptor I can see my tables and data. The Data Sets are
returning my data rows. I set the Combo Box properties to the correct
dataset. I run the program and I can navigate through my records, but when
I click the dropdown on my combo box there is no data.

For lack of I better term, I don't know what I'm doing and need some help in
figuring it out ;-)

Thanks!

Kent
 
C

Cor Ligthert

KentL,

Do you set the datasource of the combobox to the right table and as well the
displaymember and the valuemember?

Cor
 
K

KentL

Thanks for the reply
Yes I set all of that in the ComboBox Property Window. This form is
databound to daCMMS data adaptor with the dataset dsWO_Headers and the table
being WO_Headers table. I then still use the same data adaptor and use
dataset dsProjectNumbers and the table being tblApprovedProjects. I have 4
textboxes, 15 comboboxes. I can't seem to find any information as to; (1)
Is it ok to use the same data adaptor for all the datasets I will be using
as data sources for the combo boxes as well as the dataset for my form? (2)
In the Windows form designer generated code, should I be going there and
coding in the properties for my combo boxes. I have worked for two days
trying to figure this out, and I get more frustrated. I'm sure that it is
something simple that I am not doing correctly!
Thanks again for the reply!

Kent
 
K

KentL

This is the code that was generated in the Windows Form Designer generated
code.
'cboProjectNumber

'

Me.cboProjectNumber.DataBindings.Add(New
System.Windows.Forms.Binding("Text", Me.DsWO_Headers,
"KEO_WO_HEADERS.PROJECT_NUMBER"))

Me.cboProjectNumber.DataBindings.Add(New
System.Windows.Forms.Binding("SelectedValue", Me.DsProjectNumbers,
"tblApprovedProjects.Project_Number"))

Me.cboProjectNumber.DataSource = Me.DsProjectNumbers

Me.cboProjectNumber.DisplayMember = "tblApprovedProjects.Project_Number"

Me.cboProjectNumber.Location = New System.Drawing.Point(112, 120)

Me.cboProjectNumber.Name = "cboProjectNumber"

Me.cboProjectNumber.Size = New System.Drawing.Size(96, 21)

Me.cboProjectNumber.TabIndex = 3

Me.cboProjectNumber.ValueMember = "tblApprovedProjects.Project_Number"

Thanks!

Kent
 
C

Cor Ligthert

Kentl,
Thanks for the reply

I was beginning on Christmas eve here so don't expect a reply on this today
anymore, and I try it quick and dirty.

Probably you use the designer to do the bindings.
Look for the combobox datasource. The most often error is than that it is
set to the dataset. That has to be the datatable (a crosslower).

Than you have to set in the same place the displaymember and the valuemember
which are the fields in your combobox.

When it is in code it is something as

combobox1.datasource = dsWO_Headers.tables("WO_Headers"))
combobox1.displaymember = "whatever"
combobox1.valuemember = "whatever"

I hope this helps?

Cor
 

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