直接改绑定数据源--实体的属性会导致选择内容变空 【将选中项清除时】
所有改相应控件的text属性然后再写入数据源
最好将需要联动的控件设置成只读
mNoTextEdit.EditValueChanged += (s, e) =>
{
mM_QuotationBindingSource.EndEdit();
var cur = mM_QuotationBindingSource.Current as MM_Quotation;
var mNo = mNoTextEdit.EditValue as String;
if (string.IsNullOrWhiteSpace(mNo)) return;
var mm = MMUtil.GetList().FirstOrDefault(ent => ent.p_partno == mNo);//到这里正常
if (mm != null)
{
specificationTextEdit.Text = Util.V(mm.p_othername1);
unitTextEdit.Text = Util.V(mm.p_unit);
mM_QuotationBindingSource.EndEdit();
}
};
对于gridveiw的下拉联动,貌似没有上面的问题
repositoryItemSearchLookUpEdit1.EditValueChanged += (s, e) =>
{
gridView1.CloseEditor();
items_BindingSource.EndEdit();
var cur = items_BindingSource.Current as PP_MMProcessUsed;
if (cur == null) return;
var q = UseBOMList.FirstOrDefault(ent => ent.MNo == cur.MNo);
if (q == null)
{
cur.Amount = 0;
cur.MName = "";
cur.MUnit = "";
}
else
{
cur.MName = q.MName;
cur.MUnit = q.MUnit;
cur.Amount = q.Amount;
}
items_BindingSource.ResetCurrentItem();
};