如何编号DataGridView的行? [英] How to number the rows of DataGridView?
本文介绍了如何编号DataGridView的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何为datagridView的行编号?那当我添加额外的行时数字会增加?
How to number the rows of datagridView ? That when I add additional row the number increments ?
推荐答案
而是使用datagridview的RowPostPaint事件
Rather use RowPostPaint event of datagridview
void GridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
this.GridView.Rows[e.RowIndex].Cells[0].Value
= (e.RowIndex + 1).ToString();
}
这篇关于如何编号DataGridView的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文