读书人

datagridview中的checkbox 的bool值,该

发布时间: 2012-05-28 17:59:54 作者: rapoo

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)

读书人网 >C#

热点推荐