version 1.0.2005.1 final (self-servicing)
VS2005 winforms
hiya,
I have a combobox that reflects the "condition" of a product, ie NEW or OLD
If I was using simple databinding, I would databind to the "productCondition" entityCollection.
The cboProductCondition combobox would then correctly always contain only the items "NEW" and "OLD"
Unfortunately, the cboProductCondition is used as a filter to filter the contents of a datgridView.
eg, the user selects "OLD", then the datagridView will display all the OLD products within a particular product return.
So, does this mean that I need COMPLEX databinding?
The products in a datagridView are either NEW or OLD, In other words, mutually exclusive.
The datagridView will display either:
all the NEW products that comprise a product return.
OR, it will display all the OLD products that comprise a product return.
This will happen, depending on the productCondition that is selected in the cboProductCondition combobox. (using the selectedValue as a predicate)
<schema>
returnId PK
productId PK
productConditionId PK
productConditionName (added as a field mapped on a related field)
</schema>
My problem,
If I use complex databinding, then the combobox will grab ALL the current values in the entityCollection...
eg. if there are 3 OLD items in the entityCollection, then the combobox will contain:
"OLD "
"OLD "
"OLD "
...That is no use to me whatsoever.
So, how do I initially populate the combobox so that it:
1) only and always contains the items "New" and "old", regardless of what is in the entityCollection?
2) can use its "selectedValue" as a predicate to filter the datasource for the datagridView?
Below is what I have so far.At this stage, I understand the problem really well, and can clarify any ambiguity.
please help.
tblReturnCollection1.GetMulti(null);
parentBindingSource.DataSource = tblReturnCollection1;
IPredicateExpression filtReturnProductCondition = new PredicateExpression();
//returnId filter omitted for clarity.
filtReturnProductCondition.Add(PredicateFactory.CompareValue(TblReturnProductsFieldIndex.ReturnProductCondtionId, ComparisonOperator.Equal, (int)cboReturnProductCondition.SelectedValue)) ;
//So, in the above code, the cboReturnProductCondition hasn't yet been populated
tblReturnProductsCollection1.GetMulti(filtReturnProductCondition);
childBindingSource.DataSource = tblReturnProductsCollection1;
dgvReturns.DataSource = childBindingSource;
cboReturnProductCondition.DataBindings.Clear();
cboReturnProductCondition.DataBindings.Add(new Binding("SelectedValue", this.childBindingSource, myProject.TblReturnProductsFieldIndex.ReturnProductCondtionId.ToString(), true));
childBindingSourceProdCondition.DataSource = tblReturnProductsCollection1;
cboReturnProductCondition.DataSource = childBindingSourceProdCondition;