private void dataGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
  

private void dataGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
var dgv = (DataGridView)sender;
if (dgv.RowHeadersVisible)
{
Rectangle rect = new Rectangle(e.RowBounds.Left, e.RowBounds.Top,
dgv.RowHeadersWidth, e.RowBounds.Height);
rect.Inflate(-2, -2);
TextRenderer.DrawText(e.Graphics,
(e.RowIndex + 1).ToString(),
e.InheritedRowStyle.Font,
rect, e.InheritedRowStyle.ForeColor,
TextFormatFlags.Right | TextFormatFlags.VerticalCenter
);

}
}

}

05-11 14:47