Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with formating DataGridView using VB,NET

Hi,

How do you  change a DataGridView's column's background and textcolor (Red and White) if the entire column is blank using VB.NET?

Thanks,

Victor
Avatar of Sylvain Drapeau
Sylvain Drapeau
Flag of Canada image

Hello !

int RowIndex = 0;
this.dataGridView1.Rows[ RowIndex ].DefaultCellStyle.BackColor = Color.Red
this.dataGridView1.Rows[ RowIndex ].DefaultCellStyle.ForeColor = Color.White
;

Open in new window


Please confirm if this works as you wish.

Thanks !
Avatar of Victor  Charles

ASKER

Can you please send me the solution in VB.NET.

Thanks,

Victor
Which property of the Grid, should the code be included?
ASKER CERTIFIED SOLUTION
Avatar of Sylvain Drapeau
Sylvain Drapeau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

Thanks for the link.

How do I modify the code below to also change the text color (red) of the column headears if the all the rows in the column are blank?
For i = 0 To Me.C1Screen1.Rows.Count - 1
            For j = 1 To Me.C1Screen1.Columns.Count - 1
                 If Me.C1Screen1.Rows(i).Cells(j).Value = "" Then 
                    Me.C1Screen1.Rows(i).Cells(j).Style.BackColor = Color.Red
                 End If
            Next
        Next

Open in new window


Victor