I've been playing around with datagridviews for a bit and a question has came up. -> Doesn't changing a cells background work out of the CellFormatting event. I've tried this:
private void dataGridView1_CellFormatting(object sender, dataGridViewCellFormattingEventArgs e)
{
if (dataGridView1.Columns[e.ColumnIndex].Name.Equals(dnsList.First<String>()))
{
DataGridViewRow row = dataGridView1.Rows[e.RowIndex];
DataGridViewCell cell = row.Cells[e.ColumnIndex];
cell.Style.BackColor = Color.FromArgb(194, 235, 211);
}
}
Which works perfectly, whereas this:
private void ApplyColoring()
{
if (dataGridView1.DataSource != null)
{
foreach (DataGridViewRow dataGridRow in dataGridView1.Rows)
{
DataGridViewCell cell = dataGridRow.Cells[dnsList.First<String>()];
cell.Style.BackColor = Color.FromArgb(194, 235, 211);
}
}
}
Debugging tells me everything is sound, null-reference-or-whatever-exception-wise... Any tips?