首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

datagridview中的checkbox 的bool值,该如何解决

2012-05-28 
datagridview中的checkbox 的bool值请问如何从datagridview中的checkbox 提取bool值已用DataGridViewCheck

datagridview中的checkbox 的bool值
请问 如何从datagridview中的checkbox 提取bool值
已用 DataGridViewCheckBoxColumn newColumn = new DataGridViewCheckBoxColumn();
  newColumn.HeaderText = "this.studentDataSet2._Sheet1_";
  dataGridView1.Columns.Add(newColumn);

[解决办法]
if (dataGridView1.CurrentRow.Cells[1].Value.ToString() == "True")
[解决办法]
private void button1_Click(object sender, EventArgs e)
{
if (dataGridView1.Rows.Count > 0)
{
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (Convert.ToBoolean(dataGridView1.Rows[i].Cells[0].Value))
{
MessageBox.Show("选择了第" + (i + 1).ToString() + "行");
}
}
}
}

Convert.ToBoolean(dataGridView1.Rows[i].Cells[0].Value)这样就转换了

[解决办法]
遍历循环datagridview 的checkbox的那一列,然后如果值为true的话则选中不就行了!
for(int shu=0;shu<datagridview.rows.count;shu++)
{
if(Convert.ToBoolean(dgvyu.Rows[shu].Cells[0].Value) == true
{
//则选中
}
}
[解决办法]
Convert.ToBoolean(dataGridView1.Rows[i].Cells[0].Value)

热点排行