17' If LastOrderDate was more than 30 days ago AND this form's ordersOverdueCheckBox control is checked..
18IfDate.Now.Subtract(CType(e.Value, Date)).Days > 30 AndMe.orderOverdueCheckBox.Checked Then
19' Set the BackColor of the cell to yellow-green.
20 e.CellStyle.BackColor = Color.YellowGreen
The CellFormatting event occurs every time each cell is painted, so you should avoid lengthy processing when handling this event.For more information visit the link below: DataGridView.CellFormatting Event
Click the link above to download Visual Basic source code in a Visual Studio 2005 solution which demonstrates how to handle the Windows Forms DataGridView CellFormatting event to set the BackColor of a cell based on the cell's value.