1 2 3 4 5 6 7 8 9 10 11 12 13
| Protected Overrides Sub OnRowPostPaint(e As DataGridViewRowPostPaintEventArgs)
Dim strRowNumber As String = (e.RowIndex + 1).ToString()
While strRowNumber.Length < Me.RowCount.ToString().Length
strRowNumber = Convert.ToString("0") & strRowNumber
End While
Dim size As SizeF = e.Graphics.MeasureString(strRowNumber, Me.Font)
If Me.RowHeadersWidth < CInt(size.Width + 20) Then
Me.RowHeadersWidth = CInt(size.Width + 20)
End If
Dim b As Brush = SystemBrushes.ControlText
e.Graphics.DrawString(strRowNumber, Me.Font, b, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + ((e.RowBounds.Height - size.Height) / 2))
MyBase.OnRowPostPaint(e)
End Sub |
Partager