如何在复选框中键入种姓gridview值 [英] How to type caste gridview value in checkbox
本文介绍了如何在复选框中键入种姓gridview值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在复选框中键入强制转换DataGridViewCheckboxColumn字段值.
How to type cast DataGridViewCheckboxColumn field value in check box.
CheckBox asa = (CheckBox)dataGridview1.Rows[1].Cells[3];
此字段已准备就绪datagridviewchechkboxcolumn
我遇到此代码问题.....
任何人都可以帮助我.
预先感谢.
this field is allready datagridviewchechkboxcolumn
i m facing problem this code.....
Any one help me.
Thanks in advance.
推荐答案
DataGidViewCheckBoxColumn
中的单元格为DataGirdViewCheckBoxCell
类型.因此,您不能直接将DataGirdViewCheckBoxCell
强制转换为checkbox
.相反,您可以使用DataGirdViewCheckBoxCell
本身.
有关DataGirdViewCheckBoxCell
的更多信息,请参见此链接.
将DataGridViewCheckBoxCell值设置为True [ ^ ]
DataGridViewCheckBoxCell类 [
Hi,
The cells in theDataGidViewCheckBoxColumn
are of typeDataGirdViewCheckBoxCell
. So, you cannot cast directlyDataGirdViewCheckBoxCell
tocheckbox
. instead you can useDataGirdViewCheckBoxCell
itself.
refer this link for more onDataGirdViewCheckBoxCell
.
Set DataGridViewCheckBoxCell Value to True[^]
DataGridViewCheckBoxCell Class[^]
Hope it helps.
您好,
为什么要打字?您可以直接获取值.
试试这个:
Hi,
Why you want to typecast that? You can directly fetch the value.
Try this:
foreach (DataGridViewRow dataGridRow in dataGridView1.Rows)
{
if (dataGridRow.Cells["YourCheckboxColumn"].Value != null && (bool)dataGridRow.Cells["YourCheckboxColumn"].Value)
{
// Checked
}
else if (dataGridRow.Cells["YourCheckboxColumn"].Value == null)
{
// Unchecked
}
}
--Amit
--Amit
这篇关于如何在复选框中键入种姓gridview值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文