DataGridViewButtonColumn启用按钮结合布尔字段布尔、字段、按钮、DataGridViewButtonColumn

2023-09-07 09:14:26 作者:我的爱已过期

我有一个自定义对象(比如为MyObject )使用名为的IsEnabled 一个布尔属性。我约束的为MyObject 集合到的DataGridView 设置 DataPropertyName 对于每一列

I have a custom object (say MyObject) with a bool property called IsEnabled. I bound a collection of MyObject to a DataGridView setting the DataPropertyName for each column.

我想通过的IsEnabled 属性的值,以便在 DataGridViewButtonColumn 按钮。我怎样才能得到这一点没有实现自定义列?这可能吗?

I'd like to enable the buttons in a DataGridViewButtonColumn by the value of the IsEnabled property. How can I obtain this without implementing a custom column? Is it possible?

现场绑定到它不工作列...

Binding the field to the column it doesn't work...

推荐答案

看来,在一个 DataGridViewButtonColumn 不能被禁用,因此,下面的这篇文章,唯一的办法按钮获得我想要的是实现一个自定义的DataGrid列类型: http://msdn.microsoft.com/en-us/library/ms171619.aspx

It seems that buttons in a DataGridViewButtonColumn cannot be disabled, so, following this article, the only way to obtain what I want is to implement a custom DataGrid column type: http://msdn.microsoft.com/en-us/library/ms171619.aspx

不是很实用...