我遇到了数据网格视图的问题。我想逐个匹配具有特定值的所有datagrid视图行。我的代码如下所示,但它不起作用:
for(int i = 0; i < dataGridVie.RowCount;i++ ){
if(dataGridVie.Rows[i].Cells[0].Value.ToString().Trim() == "F7" && dataGridVie.Rows[i].Cells[1].Value.ToString() == "slow wave" )
count++;
}
for(int i = 0; i < dataGridVie.RowCount;i++ ){
if(dataGridVie.Rows[i].Cells[0].Value.ToString().Trim() == "F3" && dataGridVie.Rows[i].Cells[1].Value.ToString() == "slow wave" )
count++;
}
for(int i = 0; i < dataGridVie.RowCount;i++ )
{
if( dataGridVie.Rows[i].Cells[0].Value.ToString().Trim() == "T3" && dataGridVie.Rows[i].Cells[1].Value.ToString() == "slow wave" )
count++;
}
for(int i = 0; i < dataGridVie.RowCount;i++ )
{
if(dataGridVie.Rows[i].Cells[0].Value.ToString().Trim() == "C3" && dataGridVie.Rows[i].Cells[1].Value.ToString() == "slow wave")
count++;
}
for(int i = 0; i < dataGridVie.RowCount;i++ ){
if(dataGridVie.Rows[i].Cells[0].Value.ToString().Trim() == "T5" && dataGridVie.Rows[i].Cells[1].Value.ToString() == "slow wave" )
count++;
}*/
/*for(int i = 0; i < dataGridVies.RowCount;i++ )
{
if( dataGridVies.Rows[i].Cells[0].Value.ToString().Trim() == "O2" && dataGridVies.Rows[i].Cells[1].Value.ToString() == "slow wave" )
count++;
}
/*for(int i = 0; i < dataGridVie.RowCount;i++ ){
if(dataGridVie.Rows[i].Cells[0].Value.ToString().Trim() == "P2" && dataGridVie.Rows[i].Cells[1].Value.ToString() == "slow wave")
count++;
}*/
if(count==4)
{
MessageBox.Show("");
}
答案 0 :(得分:-1)
for(int i = 0; i < dataGridVie.RowCount;i++ ){
if(dataGridVie.Rows[i].Cells[0].Value.ToString().Trim() == "F7" && dataGridVie.Rows[i].Cells[1].Value.ToString() == "slow wave" )
count++;
if(dataGridVie.Rows[i].Cells[0].Value.ToString().Trim() == "F3" && dataGridVie.Rows[i].Cells[1].Value.ToString() == "slow wave" )
count++;
if( dataGridVie.Rows[i].Cells[0].Value.ToString().Trim() == "T3" && dataGridVie.Rows[i].Cells[1].Value.ToString() == "slow wave" )
count++;
if(dataGridVie.Rows[i].Cells[0].Value.ToString().Trim() == "C3" && dataGridVie.Rows[i].Cells[1].Value.ToString() == "slow wave")
count++;
if(dataGridVie.Rows[i].Cells[0].Value.ToString().Trim() == "T5" && dataGridVie.Rows[i].Cells[1].Value.ToString() == "slow wave" )
count++;
}*/
/*for(int i = 0; i < dataGridVies.RowCount;i++ )
{
if( dataGridVies.Rows[i].Cells[0].Value.ToString().Trim() == "O2" && dataGridVies.Rows[i].Cells[1].Value.ToString() == "slow wave" )
count++;
}
/*for(int i = 0; i < dataGridVie.RowCount;i++ ){
if(dataGridVie.Rows[i].Cells[0].Value.ToString().Trim() == "P2" && dataGridVie.Rows[i].Cells[1].Value.ToString() == "slow wave")
count++;
}*/
if(count==4)
{
MessageBox.Show("");
}