MLavine
MLavine

Reputation: 195

Make all cells in one row in DataGridView load bold during LoadDataRow?

Hey all: I'm trying to highlight a row in a datagridview when a value in that row changes. My code is abstracted below:

void fillTable(DataTable table, List<object> readings)
{
    foreach (object r in readings)
        LoadRow(table, r)
}

private void LoadRow(DataTable table, Object r)
{
    table.LoadDataRow(new Object[] { r.parameter1, r.parameter2, r.parameter3 }
    if (r.parameter3 == something)
        *make row bold*
}

What I want to do is make the entire row bolded if r.parameter3 is a certain value. I don't know what to put in that statement to make the row bolded (or highlighted, or whatever). I know that once I have the datagridview populated, I can do something like

table.Rows[Index].DefaultCellStyle.Font = boldFont;

but I don't know the index when im loading the row (because its being called in a loop) and I'd rather not go back through once Im done building the datagridview.

Any help is greatly appreciated. Thanks!

Upvotes: 4

Views: 6152

Answers (1)

Derek
Derek

Reputation: 8628

What about this :-

table.Rows[Index].DefaultCellStyle.Font = new Font(Yourfont, FontStyle.Bold);

Hope this helps.

Upvotes: 1

Related Questions