This is the perfect solution to my problem, I share it so that everyone has it.
In the Load event of Form the following statement is placed:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
DataGridView1.AutoGenerateColumns = False
End Sub
In the CellPainting event of the DataGridView we placed the following:
Private Sub DataGridView1_CellPainting(sender As Object, e As DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting
e.AdvancedBorderStyle.Bottom = DataGridViewAdvancedCellBorderStyle.None
If (e.RowIndex < 1 Or e.ColumnIndex < 0) Then
Return
End If
If (IsTheSameCellValue(e.ColumnIndex, e.RowIndex)) Then
e.AdvancedBorderStyle.Top = DataGridViewAdvancedCellBorderStyle.None
Else
e.AdvancedBorderStyle.Top = DataGridView1.AdvancedCellBorderStyle.Top
End If
End Sub
In the CellFormatting event of the DataGridView we placed the following:
Private Sub DataGridView1_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting
If (e.RowIndex = 0) Then
Return
End If
If (IsTheSameCellValue(e.ColumnIndex, e.RowIndex)) Then
e.Value = ""
e.FormattingApplied = True
End If
End Sub
And additional we need to create a function:
Private Function IsTheSameCellValue(ByVal column As Integer, ByVal row As Integer) As Boolean
Dim cell1 As DataGridViewCell = DataGridView1(column, row)
Dim cell2 As DataGridViewCell = DataGridView1(column, row - 1)
If (IsDBNull(cell1.Value) Or IsDBNull(cell2.Value)) Then
Return False
End If
If (cell1.Value = cell2.Value) Then
Return True
Else
Return False
End If
End Function