Combobox binding

G

Guest

Hello,
I have 6 comboboxes, that I thought I could bind to the same datasource, and
have them display different 'selectedvalue's', but apparently I can't...

My code is as follows:

dim drv as datarowview = me.listbox1.selecteditem
dim dtbDL as datatable = _dataset1.Tables(0)
dim dtvDL as new dataview(dtbDL)
dtvDL.RowFilter = "STR_ONE" = 'Matching Text'"

'Combobox 1
Me.cbo1.datasource = dtvDL
me.cbo1.ValueMember = "STR_DISPLAY_VALUE"
me.cbo1.DisplayMember = "STR_DISPLAY_VALUE"
me.cbo1.SelectedValue = drv("ITEM_1_FROM_DATABASE").ToString

'Combobox 2
Me.cbo2.datasource = dtvDL
me.cbo2.ValueMember = "STR_DISPLAY_VALUE"
me.cbo2.DisplayMember = "STR_DISPLAY_VALUE"
me.cbo2.SelectedValue = drv("ITEM_2_FROM_DATABASE").ToString

Obviously I'm not able to do this...whatever the value is in
ITEM_2_FROM_THE_DATABASE is displayed in both.

I want all 6 comboboxes to display the same drop downlist of (76) values,
but to display the corresponding value in the database for each item.

Make sense??
Do I need to declare a new dataview each time? and/or datatable??

Thanks!
amber
 
C

Cor Ligthert

Amber,

When I understand you well, than you can by creating for every combobox its
own dataview.

I hope this helps,

Cor
 
G

Guest

I'm not sure if this will help, but I was reading in Chris Sells 'Windows
Forms Binding in C#, footnote, page 482', that the data source is bound to
each combobox and is managed by a common Binding manager which in turn is
part of a Binding Context. The Binding amager keeps all comboboxes
synchronized to the same row in the database. However, if each combobox has
a different Binding context, hence a diferent Binding Manager, then the combo
boxes can show different rows from the same data source.
 

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