DATAGRIDVIEW bool getcheckboxvalue = (bool)this.DataGrid.Rows["yourcheckbox"].Cells["yourcheckbox"].Value; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 for (int i = 0; i < this.dataGridView1.Rows.Count; i++){ DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)this.dataGridView1.Rows[i].Cells[0]; if (cell.Value != null && (bool)cell.Value == true) { //处于选中状态 }} 如果你需要一选中就有效果的话,建议使用如下代码private void DATAGRIDVIEW_CurrentCellDirtyStateChanged(object sender, EventArgs e) { DATAGRIDVIEW.CommitEdit(new DataGridViewDataErrorContexts()); }private void DATAGRIDVIEW_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if ((bool)DATAGRIDVIEW.Rows[e.RowIndex].Cells[e.ColumnIndex].Value) MessageBox.Show(string.Format("选中了行{0}", e.RowIndex)); else { MessageBox.Show(string.Format("行{0}被反选了", e.RowIndex)); } } for (int i = 0; i < this.dataGridView1.Rows.Count; i++){ DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)this.dataGridView1.Rows[i].Cells[0]; if (cell.Value != null && (bool)cell.Value == true) { //处于选中状态 }} 选中 if (this.dataGridView1[列索引,行索引].FormattedValue.ToString().Trim()=="True") 未选中 if (this.dataGridView1[列索引,行索引].FormattedValue.ToString().Trim() == "False") 注意True 和 False开头字母大写 绑定数据源的DataGridView的编辑时更新 散分求一个.net写的OpenGL的火焰燃烧的程序 javascript 捕获ocx事件 在C# .net winform 中如何把字符串%E7%A4%BE%E5%8C转为汉字? 窗口的从属关系 请问原来VS.NET 2003的“检查算术上溢出/下溢出”在2005中的那儿? 怎样托动一个没有标题栏的窗体!!!!100分 很急很难的问题。在线等!! 在Remote和Server交互時,如何返回一個對象類型? 文本比较算法的问题 .net 2.0链接Oracle 10g 菜鸟:C#+sql 做餐饮系统,网上找了很多都没的,简单的也可以 帮忙!
for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
{
DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)this.dataGridView1.Rows[i].Cells[0];
if (cell.Value != null && (bool)cell.Value == true)
{
//处于选中状态
}
}
{
DATAGRIDVIEW.CommitEdit(new DataGridViewDataErrorContexts());
}private void DATAGRIDVIEW_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
if ((bool)DATAGRIDVIEW.Rows[e.RowIndex].Cells[e.ColumnIndex].Value)
MessageBox.Show(string.Format("选中了行{0}", e.RowIndex));
else
{
MessageBox.Show(string.Format("行{0}被反选了", e.RowIndex));
}
}
{
DataGridViewCheckBoxCell cell = (DataGridViewCheckBoxCell)this.dataGridView1.Rows[i].Cells[0];
if (cell.Value != null && (bool)cell.Value == true)
{
//处于选中状态
}
}
if (this.dataGridView1[列索引,行索引].FormattedValue.ToString().Trim()=="True")
未选中
if (this.dataGridView1[列索引,行索引].FormattedValue.ToString().Trim() == "False")
注意True 和 False开头字母大写