[英]Grid with checkbox column not editable
I'm new with c#. 我是C#的新手。
I have a GridView + BindingSource. 我有一个GridView + BindingSource。
I fill my binding source with list of items like this: 我用以下项目列表填充绑定源:
public class ListItem
{
public DbObject EntityObject { get; set; }
public bool Used
{
get
{
return EntityObject != null;
}
}
public int Id
{
get
{
return EntityObject == null ? 0 : EntityObject.Id;
}
}
public string Name{
get
{
return EntityObject == null ? "<no name>" : EntityObject.ToString();
}
}
}
Data shows in Grid as fine. 数据在Grid中显示良好。 But i can't check or uncheck checkboxes in Grid. 但是我无法选中或取消选中网格中的复选框。 When i not fill field Used
: 当我不填场Used
:
public bool Used
{
get; set;
}
Grid became editable again. 网格再次变为可编辑状态。 Whats cant be wrong here? 有什么不对的地方吗?
UPDATE UPDATE
Now my grid is editable but work not correctly. 现在,我的网格是可编辑的,但无法正常工作。
I have a 4 raws, 2 raws was checked: 我有4个未加工的原料,已检查2个未加工的原料:
1 unchecked
2 unchecked
3 checked
4 checked
Now i uncheck raw 3: 现在我取消选中原始3:
1 unchecked
2 unchecked
3 unchecked
4 checked
Its fine. 没关系。 Now uncheck raw 4: 现在取消选中原始4:
1 unchecked
2 unchecked
3 checked
4 unchecked
Now check raw 2: 现在检查原始2:
1 unchecked
2 checked
3 checked
4 checked
Why Grid work so strange? 为什么网格工作如此奇怪?
Currently you have read only property, if you add set
also you will able to edit 当前,您拥有只读属性,如果您添加了set
还可以进行编辑
private bool temp;
public bool Used
{
get { return temp; }
set { temp= value; }
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.