Binding Data to ComboBox and Other Controls

  • Thread starter Thread starter Jesse
  • Start date Start date
J

Jesse

Hi there,

I am trying to bind a combobox and some textboxes to a
single table in a dataset. I want it so that when a
(unique) value in the combobox is selected, the other
textboxes show information for the row in the dataset
specific to that selection. So far, i have been able to
bind the combo box to show a list of the values (primary
keys) from the table but when i change the selection in
the combo box, the textboxes do not update.

Any help would be good,
Jesse
 
Hi Jesse,

Something as this (not tested, just pasted and typed)

VB style
(for C# it is almost the same except the ";" at the ends the "[]" and the
declaration of cma)

dim cma As CurrencyManager
combobox1.BeginUpdate()
combobox1.DisplayMember = "ident"
textbox1.DataBindings.Clear()
cma = CType(BindingContext(dataset1.Tables(0)), CurrencyManager)
textbox1.DataBindings.Add(New Binding("Text", dataset1.Tables(0),
"LastName"))
combobox1.DataSource = dataset1.Tables(0)
combobox1.EndUpdate()
 
Thanks mate,

works a treat.

Appreciate it.

-----Original Message-----
Hi Jesse,

Something as this (not tested, just pasted and typed)

VB style
(for C# it is almost the same except the ";" at the ends the "[]" and the
declaration of cma)

dim cma As CurrencyManager
combobox1.BeginUpdate()
combobox1.DisplayMember = "ident"
textbox1.DataBindings.Clear()
cma = CType(BindingContext(dataset1.Tables(0)), CurrencyManager)
textbox1.DataBindings.Add(New Binding("Text", dataset1.Tables(0),
"LastName"))
combobox1.DataSource = dataset1.Tables(0)
combobox1.EndUpdate()
Hi there,

I am trying to bind a combobox and some textboxes to a
single table in a dataset. I want it so that when a
(unique) value in the combobox is selected, the other
textboxes show information for the row in the dataset
specific to that selection. So far, i have been able to
bind the combo box to show a list of the values (primary
keys) from the table but when i change the selection in
the combo box, the textboxes do not update.


.
 
Back
Top