Change Datagridview Row Color based on Cell Value with vb.net

Good Morning! It has been a busy couple days but I will update you later in the day once I get the girls off to school. For now, nothing exciting but I needed to change the row color of a datagridview row based on a cell value. Nothing complicated but it was what I needed to do yesterday. Make it a great day!

For Each row As DataGridViewRow In Me.DataGridView1.Rows
            If Not row.IsNewRow Then
                If Not row.Cells(1).Value Is DBNull.Value Then
                    If row.Cells(1).Value Is "Yes" Then
                        row.DefaultCellStyle.BackColor = Color.Red
                    End If
                End If
            End If
        Next

Technorati Tags: ,,,,,,,,,,,,

Windows Live Tags: vb.net,.NET Framework,csharp,row,Change,Datagridview,Color,Cell,Value,DBNull,DefaultCellStyle,BackColor,Cells

 

Advertisements
  1. #1 by Eugenia on March 8, 2010 - 4:55 pm

    nothing happens with that code :S

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: