1 /// <summary>
2 /// 添加行号
3 /// </summary>
4 /// <param name="sender"></param>
5 /// <param name="e"></param>
6 private void cMS_CNTRDataGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
7 {
8 DataGridView dgv = (DataGridView)sender;
9 if (dgv.Columns["rowid"] == null)
10 {
11 DataGridViewTextBoxColumn column = new DataGridViewTextBoxColumn();
12 column.Name = "rowid";
13 column.HeaderText = "序号";
14 dgv.Columns.Insert(0,column);
15 }
16 dgv.Rows[e.RowIndex].Cells["rowid"].Value = e.RowIndex;
17 }
18
2 /// 添加行号
3 /// </summary>
4 /// <param name="sender"></param>
5 /// <param name="e"></param>
6 private void cMS_CNTRDataGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
7 {
8 DataGridView dgv = (DataGridView)sender;
9 if (dgv.Columns["rowid"] == null)
10 {
11 DataGridViewTextBoxColumn column = new DataGridViewTextBoxColumn();
12 column.Name = "rowid";
13 column.HeaderText = "序号";
14 dgv.Columns.Insert(0,column);
15 }
16 dgv.Rows[e.RowIndex].Cells["rowid"].Value = e.RowIndex;
17 }
18