RowPostPaint事件
private void datagridview1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
try
{
SolidBrush b = new SolidBrush(datagridview.RowHeadersDefaultCellStyle.ForeColor);
e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), datagridview.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}