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