Datagridview rows count based on condition
Hello,
I have changed the backcolor of the rows based on condition, also i have to count the number of rows for the same condition. kindly help me.
this is my code,
try
{
if (e.ColumnIndex == this.dataGridView1.Columns["POST"].Index)
{
string RepVisits = e.Value.ToString();
if (RepVisits != null)
{
if (RepVisits == "M")
{
this.dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightPink;
}
else if (RepVisits == "P")
{
this.dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightBlue;
}
else if (RepVisits == "S")
{
this.dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightGreen;
}
else if (RepVisits == "F")
{
this.dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.LightCyan;
}
else
{
this.dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.White;
}
}
}
}
catch
{
}