感謝を!他の人が望む場合は、VBのVisual Studio 2012でテストされているバージョンがあります。 私の場合、行ヘッダーの右上に表示される数字が必要でした。
Private Sub MyDGV_RowPostPaint(sender As Object, _
e As DataGridViewRowPostPaintEventArgs) Handles MyDataGridView.RowPostPaint
' Automatically maintains a Row Header Index Number
' like the Excel row number, independent of sort order
Dim grid As DataGridView = CType(sender, DataGridView)
Dim rowIdx As String = (e.RowIndex + 1).ToString()
Dim rowFont As New System.Drawing.Font("Tahoma", 8.0!, _
System.Drawing.FontStyle.Bold, _
System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Dim centerFormat = New StringFormat()
centerFormat.Alignment = StringAlignment.Far
centerFormat.LineAlignment = StringAlignment.Near
Dim headerBounds As Rectangle = New Rectangle(_
e.RowBounds.Left, e.RowBounds.Top, _
grid.RowHeadersWidth, e.RowBounds.Height)
e.Graphics.DrawString(rowIdx, rowFont, SystemBrushes.ControlText, _
headerBounds, centerFormat)
End Sub
また、デフォルトのフォント、rowFont = grid.RowHeadersDefaultCellStyle.Font
を得ることができますが、それはのように良い見ていない可能性があります。以下のスクリーンショットは、Tahomaフォントを使用しています。
誰もがこれに直面しているとは確かではありません.Former_Load()の前にHeaderCellの値を設定できませんでした。これはフォームのCTORにあります。 –