I have the following:
a combo box, cboPrinterType
a DataSet, dsPrinterTypes
a second DataSet, dsPrinter

I want to have the combo box list the values in dsPrinterTypes, so I have
set the DisplayMember and Data Source - this works
Next I want to have the selected item in the combo box bound to dsPrinter -
this does not work.

I have tried the following:
cboPrinterType.DataBindings.Add("Text", dsPrinter.Tables(0), "printer_type")

cboPrinterType.DataBindings.Add("SelectedItem", dsPrinter.Tables(0),
"printer_type")

cboPrinterType.DataBindings.Add("SelectedValue", dsPrinter.Tables(0),
"printer_type")



None of which work. The displayed items & values listed in the combo are
text.



Any suggestions?


TIA,
Jeremy

Re: Property Binding by Kathleen

Kathleen
Thu Jul 10 12:46:08 CDT 2003

Jeremy,

What happens when it "doesn't work"? If it's out of sync with other controls
on the form, you'll have to show us how you bound them as well.

Kathleen


"Jeremy Cowles" <jeremy.stop-spam-now.cowles@asifl.com> wrote in message
news:ZBePa.2926$k85.273516@twister.tampabay.rr.com...
> I have the following:
> a combo box, cboPrinterType
> a DataSet, dsPrinterTypes
> a second DataSet, dsPrinter
>
> I want to have the combo box list the values in dsPrinterTypes, so I have
> set the DisplayMember and Data Source - this works
> Next I want to have the selected item in the combo box bound to
dsPrinter -
> this does not work.
>
> I have tried the following:
> cboPrinterType.DataBindings.Add("Text", dsPrinter.Tables(0),
"printer_type")
>
> cboPrinterType.DataBindings.Add("SelectedItem", dsPrinter.Tables(0),
> "printer_type")
>
> cboPrinterType.DataBindings.Add("SelectedValue", dsPrinter.Tables(0),
> "printer_type")
>
>
>
> None of which work. The displayed items & values listed in the combo are
> text.
>
>
>
> Any suggestions?
>
>
> TIA,
> Jeremy
>



Re: Property Binding by Jeremy

Jeremy
Thu Jul 10 14:16:50 CDT 2003

Yes, it does not select the actual value that comes from the database, it
just selects the first value in the list. If i make the combo editable (as
it is by default), and then I bind the "Text" property, it works fine
(meaning: it shows/selects the proper value from the list).

This behaviour has nothing to do with other controls, but as you requested,
I have posted my binding routines.

Thanks for the reply



Private Sub BindControls()

Me.cboConnection.DataSource = dsConnType.Tables(0)

Me.cboConnection.DisplayMember = "connection_type"

Me.cboConnection.ValueMember = "connection_type"

Me.cboConnection.DataBindings.Add("Text", dsPrinter.Tables(0),
"connection_type")

Me.cboType.DataSource = dsPrintType.Tables(0)

Me.cboType.DisplayMember = "printer_type"

Me.cboType.ValueMember = "printer_type"

Me.cboType.DataBindings.Add("Text", dsPrinter.Tables(0), "printer_type")

Me.txtPrinterID.DataBindings.Add("Text", dsPrinter.Tables(0),
"printer_id")

Me.txtDescription.DataBindings.Add("Text", dsPrinter.Tables(0),
"description")

Me.txtIPAddress.DataBindings.Add("Text", dsPrinter.Tables(0),
"ip_address")

Me.txtIPPort.DataBindings.Add("Text", dsPrinter.Tables(0), "ip_port")

Me.txtLocalPort.DataBindings.Add("Text", dsPrinter.Tables(0),
"local_port")

End Sub



Private Sub UnbindControls()

cboConnection.DisplayMember = ""

cboConnection.ValueMember = ""

Me.cboConnection.DataBindings.Clear()

Me.cboConnection.DataSource = Nothing

cboType.DisplayMember = ""

cboType.ValueMember = ""

Me.cboType.DataBindings.Clear()

Me.cboType.DataSource = Nothing

Me.txtPrinterID.DataBindings.Clear()

Me.txtDescription.DataBindings.Clear()

Me.txtIPAddress.DataBindings.Clear()

Me.txtIPPort.DataBindings.Clear()

Me.txtLocalPort.DataBindings.Clear()

End Sub



Jeremy



"Kathleen Dollard" <kathleen@mvps.org> wrote in message
news:eBm3iswRDHA.1688@TK2MSFTNGP11.phx.gbl...
> Jeremy,
>
> What happens when it "doesn't work"? If it's out of sync with other
controls
> on the form, you'll have to show us how you bound them as well.
>
> Kathleen
>
>
> "Jeremy Cowles" <jeremy.stop-spam-now.cowles@asifl.com> wrote in message
> news:ZBePa.2926$k85.273516@twister.tampabay.rr.com...
> > I have the following:
> > a combo box, cboPrinterType
> > a DataSet, dsPrinterTypes
> > a second DataSet, dsPrinter
> >
> > I want to have the combo box list the values in dsPrinterTypes, so I
have
> > set the DisplayMember and Data Source - this works
> > Next I want to have the selected item in the combo box bound to
> dsPrinter -
> > this does not work.
> >
> > I have tried the following:
> > cboPrinterType.DataBindings.Add("Text", dsPrinter.Tables(0),
> "printer_type")
> >
> > cboPrinterType.DataBindings.Add("SelectedItem", dsPrinter.Tables(0),
> > "printer_type")
> >
> > cboPrinterType.DataBindings.Add("SelectedValue", dsPrinter.Tables(0),
> > "printer_type")
> >
> >
> >
> > None of which work. The displayed items & values listed in the combo
are
> > text.
> >
> >
> >
> > Any suggestions?
> >
> >
> > TIA,
> > Jeremy
> >
>
>
>


Re: Property Binding by Kathleen

Kathleen
Fri Jul 11 11:59:54 CDT 2003

Jeremy,

So if it is disabled, it won't show the correct value?

Kathleen


"Jeremy Cowles" <jeremy.stop-spam-now.cowles@asifl.com> wrote in message
news:CYiPa.79628$ic1.1495320@twister.tampabay.rr.com...
> Yes, it does not select the actual value that comes from the database, it
> just selects the first value in the list. If i make the combo editable (as
> it is by default), and then I bind the "Text" property, it works fine
> (meaning: it shows/selects the proper value from the list).
>
> This behaviour has nothing to do with other controls, but as you
requested,
> I have posted my binding routines.
>
> Thanks for the reply
>
>
>
> Private Sub BindControls()
>
> Me.cboConnection.DataSource = dsConnType.Tables(0)
>
> Me.cboConnection.DisplayMember = "connection_type"
>
> Me.cboConnection.ValueMember = "connection_type"
>
> Me.cboConnection.DataBindings.Add("Text", dsPrinter.Tables(0),
> "connection_type")
>
> Me.cboType.DataSource = dsPrintType.Tables(0)
>
> Me.cboType.DisplayMember = "printer_type"
>
> Me.cboType.ValueMember = "printer_type"
>
> Me.cboType.DataBindings.Add("Text", dsPrinter.Tables(0),
"printer_type")
>
> Me.txtPrinterID.DataBindings.Add("Text", dsPrinter.Tables(0),
> "printer_id")
>
> Me.txtDescription.DataBindings.Add("Text", dsPrinter.Tables(0),
> "description")
>
> Me.txtIPAddress.DataBindings.Add("Text", dsPrinter.Tables(0),
> "ip_address")
>
> Me.txtIPPort.DataBindings.Add("Text", dsPrinter.Tables(0), "ip_port")
>
> Me.txtLocalPort.DataBindings.Add("Text", dsPrinter.Tables(0),
> "local_port")
>
> End Sub
>
>
>
> Private Sub UnbindControls()
>
> cboConnection.DisplayMember = ""
>
> cboConnection.ValueMember = ""
>
> Me.cboConnection.DataBindings.Clear()
>
> Me.cboConnection.DataSource = Nothing
>
> cboType.DisplayMember = ""
>
> cboType.ValueMember = ""
>
> Me.cboType.DataBindings.Clear()
>
> Me.cboType.DataSource = Nothing
>
> Me.txtPrinterID.DataBindings.Clear()
>
> Me.txtDescription.DataBindings.Clear()
>
> Me.txtIPAddress.DataBindings.Clear()
>
> Me.txtIPPort.DataBindings.Clear()
>
> Me.txtLocalPort.DataBindings.Clear()
>
> End Sub
>
>
>
> Jeremy
>
>
>
> "Kathleen Dollard" <kathleen@mvps.org> wrote in message
> news:eBm3iswRDHA.1688@TK2MSFTNGP11.phx.gbl...
> > Jeremy,
> >
> > What happens when it "doesn't work"? If it's out of sync with other
> controls
> > on the form, you'll have to show us how you bound them as well.
> >
> > Kathleen
> >
> >
> > "Jeremy Cowles" <jeremy.stop-spam-now.cowles@asifl.com> wrote in message
> > news:ZBePa.2926$k85.273516@twister.tampabay.rr.com...
> > > I have the following:
> > > a combo box, cboPrinterType
> > > a DataSet, dsPrinterTypes
> > > a second DataSet, dsPrinter
> > >
> > > I want to have the combo box list the values in dsPrinterTypes, so I
> have
> > > set the DisplayMember and Data Source - this works
> > > Next I want to have the selected item in the combo box bound to
> > dsPrinter -
> > > this does not work.
> > >
> > > I have tried the following:
> > > cboPrinterType.DataBindings.Add("Text", dsPrinter.Tables(0),
> > "printer_type")
> > >
> > > cboPrinterType.DataBindings.Add("SelectedItem", dsPrinter.Tables(0),
> > > "printer_type")
> > >
> > > cboPrinterType.DataBindings.Add("SelectedValue", dsPrinter.Tables(0),
> > > "printer_type")
> > >
> > >
> > >
> > > None of which work. The displayed items & values listed in the combo
> are
> > > text.
> > >
> > >
> > >
> > > Any suggestions?
> > >
> > >
> > > TIA,
> > > Jeremy
> > >
> >
> >
> >
>