Are you binding both combo boxes to the QualityValues table
to show the available values, and then one should be stored in
Quality_Day and one in Quality_Night in the [TrafficSign] table?
I'm doing this one one of my forms. The user can select a product type.
The dropdown list shows all the values from the ProductType table,
but when I save it, it saves it to the Product table.
Do accomplish this (double binding), I use two BindingSource components.
TypeListBindingSource -- for the table displaying the possible values
ProductBindingSource -- for the table where I'm going to
store the result. This binding source is used by the rest of my fields
as well.
I did my data binding in design mode; here is the code generated for the
data
bindings. This is in VB, but it should be almost identical in C#.
ProductTypeComboBox.DataBindings.Add(New _
System.Windows.Forms.Binding("SelectedValue", _
Me.ProductBindingSource, "ProductType", True))
ProductTypeComboBox.DataSource = Me.TypeListBindingSource
ProductTypeComboBox.DisplayMember = "TypeName"
ProductTypeComboBox.ValueMember = "TypeValue"
Hope this helps.
Robin S.
----------------------------------------------------
[quoted text, click to view] > public void BindPopup(ComboBox box,
> string popupTab, string popupIDCol, string
> popupDescCol,
> string dataTab, string dataCol)
> {
> box.DropDownStyle = ComboBoxStyle.DropDownList;
> box.DataSource = globalDataSet.Tables[popupTab];
> box.DisplayMember = popupDescCol;
> box.ValueMember = popupIDCol;
***THIS LINE IS REDUNDANT. You have already bound the combobox with the
previous
***statements.
[quoted text, click to view] > box.DataBindings.Add("SelectedValue",
> globalDataSet.Tables[dataTab], dataCol);
> box.SelectedIndexChanged += new EventHandler(DataChangedHandler)
> }
[quoted text, click to view] ""Déjà-vu"" <d-e-j-a-v-u@web.de> wrote in message
news:1hru9cs.y6sb86wkabewN%d-e-j-a-v-u@web.de...
> Hi everybody,
>
> I have a configuration with popups, that look something like this:
>
> CREATE TABLE TrafficSign(
> ID NUMBER,
> LocationInfo TEXT,
> Quality_Day NUMBER,
> Quality_Night NUMBER
> ...
> )
>
> CREATE TABLE QualityValues(
> ID NUMBER,
> Desc TEXT
> )
>
> The idea is that both Quality_XXX columns reference a row in the
> QualityValues table. (which I would assume as a typical
> "popup/combobox" scenario)
> Now my form shows the data of exactly one TrafficSign.
> It contains two ComboBoxes: one for the Quality_Day, one for the
> Quality_Night.
> My DataSet contains both tables "TrafficSign" and "QualityValues", the
> latter only once.
> The ComboBoxes are bound to the DataSet by the following sequence:
>
> public void BindPopup(ComboBox box,
> string popupTab, string popupIDCol, string
> popupDescCol,
> string dataTab, string dataCol)
> {
> box.DropDownStyle = ComboBoxStyle.DropDownList;
> box.DataSource = globalDataSet.Tables[popupTab];
> box.DisplayMember = popupDescCol;
> box.ValueMember = popupIDCol;
> box.DataBindings.Add("SelectedValue",
> globalDataSet.Tables[dataTab], dataCol);
> box.SelectedIndexChanged += new EventHandler(DataChangedHandler)
> }
>
>
> The function BindPopup is called twice with different parameters.
>
> public void FormLoadHandler(...)
> {
> ...
> BindPopup(visDay, "VisibilityValues", "ID", "Desc", "TrafficSign",
> "Visibility_Day");
> BindPopup(visNight, "VisibilityValues", "ID", "Desc",
> "TrafficSign", "Visibility_Night");
> ...
> }
>
> Now the Problem:
> When I change the value of one of the ComboBoxes lets say "visDay" the
> other changes
> to the same value (which is also reflected in the data row later.
> What I want (of course) is that both values will change individually.
>
> What I don't really want is to duplicate the QualityValues table in
> the DataSet.
> Is there another way (i.e. install different instances of
> CurrencyManagers in the data binding)
> to achieve the desired behaviour?
> Any ideas are very much appreciated!
>
> Tilman
>
>
> PS:
> The project uses .NET CF 2.0.
> For debugging purposes I also have a .NET project that runs the same
> app on the desktop.
> The behavior shows up in both cases.
>
>