Partial Public Class Form1 Public Sub New() InitializeComponent() DataGridView1.AllowUserToAddRows = False DataGridView1.RowCount = 30 DataGridView1.ColumnCount = 3 DataGridView1.EditMode = DataGridViewEditMode.EditOnEnter End Sub Private Sub DataGridView1_CellFormatting(ByVal sender As Object, _ ByVal e As DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting If (e.RowIndex + 1) Mod 5 = 0 Then e.CellStyle.BackColor = Color.Yellow End If If e.Value = "1" Then e.CellStyle.BackColor = Color.Red ElseIf e.Value = "2" Then e.CellStyle.BackColor = Color.Green ElseIf e.Value = "3" Then e.CellStyle.BackColor = Color.Blue End If End Sub End Class