//显示行号
private void
dgv_list_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs
e)
{
Rectangle rectangle = new
Rectangle(e.RowBounds.Location.X,
e.RowBounds.Location.Y,
dgv_list.RowHeadersWidth -
4,
e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex +
1).ToString(),
dgv_list.RowHeadersDefaultCellStyle.Font,
rectangle,
dgv_list.RowHeadersDefaultCellStyle.ForeColor,
TextFormatFlags.VerticalCenter |
TextFormatFlags.Right);
}
C#datagridview显示行号,布布扣,bubuko.com
原文:http://www.cnblogs.com/seven4027/p/3629118.html