【发布时间】:2011-06-17 01:10:55
【问题描述】:
我有一个实现INotifyPropertyChanged 的基类:
protected void OnNotifyChanged(string pName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(pName));
}
}
public event PropertyChangedEventHandler PropertyChanged;
我有一个带有属性Latitude 的派生类,如下所示:
private double latitude;
public double Latitude
{
get { return latitude; }
set { latitude = value; OnNotifyChanged("Latitude"); }
}
我的派生类也有一个方法Fly 可以操作Latitude。
我还有一个表单,其 TextBox 绑定到我的派生类的 Latitude:
txtLat.DataBindings.Clear();
txtLat.DataBindings.Add("Text", bindSrc, "Latitude");
一个线程用于启动Fly,如下所示:
Thread tFly = new Thread(f.Fly);
tFly.IsBackground = true;
tFly.Start();
当Latitude改变时,抛出异常:
DataBinding cannot find a row in the list that is suitable for all bindings.
【问题讨论】:
标签: c# winforms multithreading binding