我用模板编辑给datagridview 中combobox添加了两个项:开和关,我现在做了一个循环,把datagridview里每一行的“开”或者“关”读过来。
请教一下:如果才能获取选中的是“开”还是“关”?
谢谢
下面是我写的代码:
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{ if (dataGridView1.Rows[i].Cells["Control"].Value.ToString()=="开")//这里不对,不知道怎么改
{
}
else
{
。
}
}
请教一下:如果才能获取选中的是“开”还是“关”?
谢谢
下面是我写的代码:
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{ if (dataGridView1.Rows[i].Cells["Control"].Value.ToString()=="开")//这里不对,不知道怎么改
{
}
else
{
。
}
}
bool blcheckall = true;
foreach (GridViewRow gvr in GridView1.Rows)
{
CheckBox cb1 = (CheckBox)gvr.FindControl("checkbox");
if (cb1.Checked == false)
{
blcheckall = false;
break;
}
}
if (blcheckall == true)
{
cb.Checked = true;
}
else
{
cb.Checked = false;
}
string selectValue =(string)(this.dataGridView1.Rows[e.RowIndex].Cells[1] as DataGridViewComboBoxCell).Value;
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
string s = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
MessageBox.Show(s);
}
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{ DataGridViewComboBoxCell dgvCmbCel= dataGridView1.Rows[i].Cells[这里指定开关那一列的索引].Value.ToString()=="开") as DataGridViewComboBoxCell
if(DataGridViewComboBoxCell.Value.toString()=="开")
{
}
}
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{ DataGridViewComboBoxCell dgvCmbCel= dataGridView1.Rows[i].Cells[这里指定开关那一列的索引] as DataGridViewComboBoxCell
if(DataGridViewComboBoxCell.Value.toString()=="开")
{
}
}
www.bonzerreport.com