Look at the following example
http://www.vbforums.com/showpost.php...66&postcount=6
In this example code taken from the project link above if a column named column1 has a length of 4 it gets a new font. Then for you to do the background colors add in your logic in InvokeBanding or ConditionsBandingPrep. Here it is shown in InvokeBanding.
Code:
Module DataGridViewExtensions
Private ConditionalFont As Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, _
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
<System.Diagnostics.DebuggerStepThrough()> _
<Runtime.CompilerServices.Extension()> _
Public Sub InvokeBanding(ByVal sender As Windows.Forms.DataGridView)
For Each band As DataGridViewBand In sender.Rows
If band.Tag IsNot Nothing Then
band.DefaultCellStyle.Font = CType(band.Tag, Font)
band.DefaultCellStyle.BackColor = Color.Cyan
End If
Next
End Sub
<System.Diagnostics.DebuggerStepThrough()> _
<Runtime.CompilerServices.Extension()> _
Public Sub ConditionsBandingPrep(ByVal sender As Windows.Forms.DataGridView)
For Row As Integer = 0 To sender.Rows.Count - 1
If sender.Rows(Row).Cells("Column1").Value.ToString.Length = 4 Then
sender.Rows(Row).Tag = ConditionalFont
End If
Next
End Sub
<System.Diagnostics.DebuggerStepThrough()> _
<Runtime.CompilerServices.Extension()> _
Public Sub ConditionsBandingPrep(ByVal sender As Windows.Forms.DataGridView, _
ByVal Rows As Integer)
For row As Integer = sender.Rows.Count - 1 To Rows Step -1
If sender.Rows(row).Cells("Column1").Value.ToString.Length = 4 Then
sender.Rows(row).Tag = ConditionalFont
End If
Next
End Sub
End Module