Private Sub DataGridView1_CellPainting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting
If e.RowIndex = -1 Then
Dim img As Image
img = Image.FromFile("D:\WindowsApplication1\Resources\Header.png")
TekenAchtergrond(e.Graphics, img, e.CellBounds, 1)
Dim format1 As StringFormat
format1 = New StringFormat
format1.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show
Dim ef1 As SizeF = e.Graphics.MeasureString(e.Value, Me.Font, New SizeF(CType(e.CellBounds.Width, Single), CType(e.CellBounds.Height, Single)), format1)
Dim txts As Size
txts = Drawing.Size.Empty
txts = Drawing.Size.Ceiling(ef1)
e.CellBounds.Inflate(-4, -4)
Dim txtr As Rectangle = e.CellBounds
txtr = HAlignWithin(txts, txtr, ContentAlignment.MiddleCenter)
txtr = VAlignWithin(txts, txtr, ContentAlignment.MiddleCenter)
Dim brush2 As Brush
format1 = New StringFormat
format1.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show
brush2 = New SolidBrush(Color.FromArgb(21, 66, 139))
e.Graphics.DrawString(e.Value, Me.Font, brush2, CType(txtr, RectangleF), format1)
brush2.Dispose()
Dim recBorder As New Rectangle(e.CellBounds.X - 1, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height - 1)
e.Graphics.DrawRectangle(Pens.LightSlateGray, recBorder)
e.Handled = True
End If
End Sub