473,396 Members | 2,057 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Combobox binding

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

Nov 22 '05 #1
3 4546
Amber,

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

I hope this helps,

Cor

"amber" <am***@discussions.microsoft.com>
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

Nov 22 '05 #2
do what you want.

:-)
Nov 22 '05 #3
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.

"amber" wrote:
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

Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: NCrum | last post by:
I want to set the Default value of a Combobox for any changeable record and have got this working but it is totaly unsatisfactory see the code below I loop through the items in the Combo looking...
1
by: Bruce | last post by:
Hi, there, I meet a problem about comboBox binding. -------------------- Database: Northwind Tables: 1) Products 2) Categories I create a form (named "form1") to edit the record from...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
2
by: shumaker | last post by:
I have a combobox that is very much like the one found in the RSS project here: http://msdn.microsoft.com/vstudio/express/visualCSharp/learning/ My projectNameComboBox basically is filled with a...
5
by: Joe | last post by:
Hi I am adding a class to a ComboBox - and all is fine except that I fill the combobox on the Form_Load Method and it causes the method private void comboBox2_SelectedIndexChanged(object...
0
by: Frnak McKenney | last post by:
Can I use a bound ComboBox for both browsing and editing? I'm working on a small, standalone database application using Visual C#.NET 2003 and an Access data file. In order to keep the number...
19
by: active | last post by:
I'm using a ComboBox to display objects of a class I've defined, say CQQ. Works great except somehow I occasionally set an Item to a String object instead of an object of type CQQ. It looks...
3
by: Simon Tamman | last post by:
I've come across an interesting bug. I have workarounds but i'd like to know the root of the problem. I've stripped it down into a short file and hope someone might have an idea about what's going...
2
by: David Jackson | last post by:
Hello, I have an unbound DataGridView of which one of the columns is a ComboBox colum containing category data, plus an additional option called <newSo when the ComboBox is dropped down it looks...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.