我有一个自定义控件(Windows Form),它是一个查找文本框。控件上的一个属性是当前选择,它是一个包含“标识符”,“代码”和“描述”的自定义对象。该属性使用BindingSource进行数据绑定。
显示信息非常好用。另一方面,无论我将更新设置为OnValidate还是OnValueChange,它都不会更新BindingSource。我是否遗漏了什么以使其自动更新?
private System.Windows.Forms.BindingSource buildPlanComponentDataBindingSource;
public void LoadBuildPlan(string itemNumber)
{
var buildPlanComponents = BuildPlan.LoadBuildPlanComponents(itemNumber, AutomaticPrice);
buildPlanComponentDataBindingSource.DataSource = buildPlanComponents;
AssemblyNumber = itemNumber;
}
[Bindable(true)]
[DefaultValue(null)]
public ILookupSelection CurrentSelection
{
get
{
if (currentSelection == null)
currentSelection = new LookupSelection {Code = txtLookup.Text};
return currentSelection;
}
set
{
if (value == null) return;
currentSelection = value;
SetText(currentSelection, DisplayText);
SetDescription(currentSelection, DisplayDescription);
}
}