Question : datagridview VS2008, bold a row

How do I bold a row in a datagridview?

I couldn't find a way to do it, so I decided to try to bold columns.  This code returns "object not sent to an instance of the object"

                    if (BoldIt)
                    {
                        //TODO:  20091119  figure out how to bold
                        DataGridViewRow dr17 = this.dgvMain.CurrentRow;
                        int dr17I = dr17.Index;
                        this.dgvMain[0, dr17I].Style.Font = new System.Drawing.Font(this.dgvMain[0, dr17I].Style.Font.FontFamily,
                            this.dgvMain[0, dr17I].Style.Font.Size, FontStyle.Bold);
                        //dR.Font = new System.Drawing.Font(dR.Font.FontFamily, dR.Font.Size, FontStyle.Bold);
                    }

Answer : datagridview VS2008, bold a row

Just replace the code you have in your if-statement with the code in the following code snippet and you should be fine. There are probably other ways to do this, but this was the first I found, for now.

Hope it helps,

Nate

1:
2:
3:
4:
5:
6:
7:
8:
// 'vw' is the name of your DataGridView
DataGridViewRow row = vw.CurrentRow;
DataGridViewCellStyle style = new DataGridViewCellStyle(row.InheritedStyle);
style.Font = new Font((style.Font ?? vw.Font), FontStyle.Bold);
 
foreach (DataGridViewCell cell in row.Cells)
{ cell.Style = style; }
vw.InvalidateRow(row.Index);
Random Solutions  
 
programming4us programming4us