4

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!

4

1 回答 1

1

那这个呢 :-

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

希望这可以帮助。

于 2012-09-26T19:52:49.917 回答