如何为datagridview增加序号列

来源:互联网 发布:pscc2017语言包mac 编辑:程序博客网 时间:2024/05/02 01:00
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
    foreach (DataGridViewRow row in dataGridView1.Rows)
    {
        row.Cells[0].Value = row.Index+1;
    }
}
原创粉丝点击