如何在复选框中键入种姓gridview值 [英] How to type caste gridview value in checkbox

查看:62
本文介绍了如何在复选框中键入种姓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 the DataGidViewCheckBoxColumn are of type DataGirdViewCheckBoxCell. So, you cannot cast directly DataGirdViewCheckBoxCell to checkbox. instead you can use DataGirdViewCheckBoxCell itself.

refer this link for more on DataGirdViewCheckBoxCell.

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屋!

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