private void metroGrid1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (this.metroGrid1.Columns[e.ColumnIndex].DataPropertyName == "Date 1") try { var EMIDate1 = Convert.ToDateTime(metroGrid1.Rows[e.RowIndex].Cells["date1DataGridViewTextBoxColumn"].Value); if (EMIDate1 <= DateTime.Today) { e.CellStyle.BackColor = Color.DarkRed; e.CellStyle.ForeColor = Color.White; int countDarkRed = 0; for (int i = 0; i < metroGrid1.RowCount; i++) { if (e.CellStyle.BackColor == Color.DarkRed) ++countDarkRed; labelEMI.Text = "Total EMI due as on today:" + countDarkRed; } } } catch { } }
labelEMI.Text = string.Format("Total EMI due as on today: {0}", metroGrid1.Rows.Cast<DataGridViewRow>() .Count(r=>r.Cells["Date 1"].Style.BackColor == Color.DarkRed));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)