添加序号列,需要给DataGridView对象添加【显示】事件。

表格对象属性【显示】中的CellPainting,添加事件dataGridView1_CellPainting,然后编辑cs文件,给事件添加序号逻辑,代码如下:
1 | //注册事件 this.dataGridView1.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.dataGridView1_CellPainting); |
好了,记录到这里,如有问题,欢迎大家联系我讨论。

书山有路勤为径,学海无涯苦作舟。
欢迎关注微信公众号:【乐知付加密平台】,您的网络资源可变现
一起学习,一起进步。
