我有数据网格视图,其中有些行是红色的,有些是绿色的,现在我想获得仅绿色的行的行数。如何获得
以下是我改变颜色的方法
for (int i = IndexNumberOfGridReceiver; i < WhatsAppCheckTotal - 1; i++)
{
if (form1.gridReceiver.Rows[i].Cells[1].Value.ToString().Equals(csvRow))
{
form1.gridReceiver.Rows[i].DefaultCellStyle.ForeColor = Color.Green;
}
else
{
form1.gridReceiver.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
}
IndexNumberOfGridReceiver = i;
}
答案 0 :(得分:0)
你被困在哪里?
int greenRows = 0;
for (int i = IndexNumberOfGridReceiver; i < WhatsAppCheckTotal - 1; i++)
{
if (form1.gridReceiver.Rows[i].Cells[1].Value.ToString().Equals(csvRow))
{
greenRows++;
form1.gridReceiver.Rows[i].DefaultCellStyle.ForeColor = Color.Green;
}
else
{
form1.gridReceiver.Rows[i].DefaultCellStyle.ForeColor = Color.Red;
}
IndexNumberOfGridReceiver = i;
}