【发布时间】:2010-10-28 12:06:00
【问题描述】:
考虑以下类:
class A : Idata
{
private int _id;
//other private fields
public int Id
{
get { return _id; }
set { _id = value; }
}
//other property
}
class B : A
{
private int _field;
//other private fields
public int Field
{
get { return _field; }
set { _field = value; }
}
//other property
}
class BCollection : Collection
{
////
}
我正在尝试将 B 的集合(由 A 对象组成)绑定到数据网格,但出现以下错误: “对象'A'上的属性访问器'Id'抛出了闲置的执行:'对象与目标类型不匹配'” 事件虽然来自 A 的所有数据都到达 B
我该怎么办?
谢谢!
【问题讨论】:
-
“B 的集合(由 A 对象组成)”是什么意思?为了使这种数据绑定工作,您的集合需要是同质的。
-
“B 的集合(由 A 对象组成)”? -> 是的。但显然它有效!
标签: c# inheritance datagrid