private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
 2         {
 3             var dgv = (DataGridView)sender;
 4             if (dgv.RowHeadersVisible)
 5             {
 6                 Rectangle rect = new Rectangle(e.RowBounds.Left, e.RowBounds.Top,
 7                                                dgv.RowHeadersWidth, e.RowBounds.Height);
 8                 rect.Inflate(-2-2);
 9                 TextRenderer.DrawText(e.Graphics,
10                     (e.RowIndex + 1).ToString(),
11                     e.InheritedRowStyle.Font,
12                     rect, e.InheritedRowStyle.ForeColor,
13                     TextFormatFlags.Right | TextFormatFlags.VerticalCenter
14                     );
15 
16             }
17         }

相关文章:

  • 2021-12-24
  • 2021-11-29
  • 2022-02-25
  • 2021-12-26
  • 2021-11-23
猜你喜欢
  • 2022-01-26
  • 2021-09-11
  • 2021-08-26
  • 2021-11-25
相关资源
相似解决方案