//最简单的方法是在Datagridview的事件RowPostPaint事件下面添加如下代码即可

 private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            SolidBrush b = new SolidBrush(this.dataGridView1.RowHeadersDefaultCellStyle.ForeColor);
            e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), this.dataGridView1.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);


        } 

 

相关文章:

  • 2022-02-20
  • 2021-11-25
  • 2021-08-26
  • 2021-09-11
  • 2021-10-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-22
  • 2022-02-25
  • 2022-01-30
  • 2022-02-06
相关资源
相似解决方案