DataGridView中实现自动编号

private void materialCheckGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
    Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
        e.RowBounds.Location.Y,
        materialCheckGridView.RowHeadersWidth - 4,
        e.RowBounds.Height);
    TextRenderer.DrawText(e.Graphics,
            (e.RowIndex + 1).ToString(),
            materialCheckGridView.RowHeadersDefaultCellStyle.Font,
            rectangle,
            materialCheckGridView.RowHeadersDefaultCellStyle.ForeColor,
            TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}

 

相关文章:

  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-09
  • 2022-01-02
  • 2021-07-31
  • 2021-07-25
  • 2022-03-02
相关资源
相似解决方案