DataGridViewCheckBoxCell类型的DataGridView列是不间断的/禁用的 [英] DataGridView column of type DataGridViewCheckBoxCell is constantly readonly/disabled

查看:156
本文介绍了DataGridViewCheckBoxCell类型的DataGridView列是不间断的/禁用的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用.NET Windows Forms DataGridView,我需要编辑一个DataBound列(绑定在一个布尔DataTable列上)。为此,我指定这样的单元格模板:



DataGridViewColumn column = new DataGridViewColumn(new DataGridViewCheckBoxCell());



你看,我需要一个复选框单元格模板。



我遇到的问题是这个列是不断被readonly / disabled,就像它是TextBox类型一样。任何关于如何处理DataGridView的可编辑复选框列的想法?



更新:对于Windows窗体,请。



谢谢。

解决方案

好了,经过4个多小时的调试,我发现DataGridView行的高度太小,无法勾选复选框,所以它根本没有显示。



作为解决方案,您可以将AutoSizeRowsMo​​de设置为AllCells。



richDataGrid.AutoSizeRowsMo​​de = System.Windows.Forms.DataGridViewAutoSizeRowsMo​​de.AllCells;


I am using a .NET Windows Forms DataGridView and I need to edit a DataBound column (that binds on a boolean DataTable column). For this I specify the cell template like this:

DataGridViewColumn column = new DataGridViewColumn(new DataGridViewCheckBoxCell());

You see that I need a CheckBox cell template.

The problem I face is that this column is constantly readonly/disabled, as if it would be of TextBox type. It doesn't show a checkbox at all.

Any thoughts on how to work with editable checkbox columns for DataGridView?

Update: For windows forms, please.

Thanks.

解决方案

Well, after more than 4 hours of debugging, I have found that the DataGridView row height was too small for the checkbox to be painted, so it was not displayed at all. I have found this after an accidental row height resizing.

As a solution, you can set the AutoSizeRowsMode to AllCells.

richDataGrid.AutoSizeRowsMode = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;

这篇关于DataGridViewCheckBoxCell类型的DataGridView列是不间断的/禁用的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆