Private Sub DrawRowHeader(ByVal dg As DataGrid, ByVal g As Graphics)
If Me.DesignMode Then Exit Sub
Try
Dim RowCount As Integer
If dg.DataSource Is Nothing Then
RowCount = -1
Else
RowCount = dg.BindingContext(dg.DataSource, dg.DataMember).Count
End If
If RowCount > 0 Then
Dim i As Integer
Dim j As Integer
Dim intCount As Integer = 0
Dim intTop As Integer
Dim intFirstRow As Integer
Dim intFirstRowTop As Integer
Dim NumberWidth As Integer
Dim blnRedFont As Boolean
Dim blnNoTableStyle As Boolean
Dim intColunmCount As Integer
Dim intItemIndex As Integer
Dim Rect As Rectangle
Dim sb As New SolidBrush(dg.BackColor)
Dim drs() As DataRow
Dim dv As DataView
Dim dgcs As DataGridColumnStyle
Dim strFieldCode As String
Dim strTemp As String
Dim strFormat As New StringFormat
If TypeOf Me.DataSource Is DataTable Then
dv = CType(Me.DataSource, DataTable).DefaultView
ElseIf TypeOf Me.DataSource Is DataView Then
dv = CType(Me.DataSource, DataView)
End If
If blnNoTableStyle Then
dg.RowHeaderWidth = NumberWidth
ElseIf NumberWidth > dg.TableStyles(0).RowHeaderWidth Then
dg.TableStyles(0).RowHeaderWidth = NumberWidth
End If
For i = intFirstRow To RowCount - 1
intTop = dg.GetCellBounds(i, 0).Top + 2
g.DrawString(CStr(i + 1), dg.Font, New SolidBrush(Color.Black), 15, intTop)
next
end sub