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

asked on

Help with alternating Background color of rows and columns of DataGridView that comes with VS2010

Hi,

How do you alternate the backgroud color of rows and columns in a datagriview?

Thanks,

Victor
SOLUTION
Avatar of UnifiedIS
UnifiedIS

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
Avatar of Victor  Charles

ASKER

Thanks, I noticed there isn't a property for columns. How do you specify the backgroumd and forecolor of a specific column?
ASKER CERTIFIED SOLUTION
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
Also you can change the backColor and the foreColor of a specific Cell in a specific coloumn according to its Value..with the Cell Foratting Event...
 Private Sub DataGridView1_CellFormatting(sender As Object, e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting
        If e.ColumnIndex = 3 Then
            If e.Value = "aaa" Then
                e.CellStyle.BackColor = Color.Green
                e.CellStyle.ForeColor = Color.Red
            End If
        End If
    End Sub

Open in new window



Yiannis
It Works!

Thanks,

Victor
Thank you for the extra information.
Thank You for both solutions.