1 private void dgv_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
2 {
3 try
4 {
5 SolidBrush v_SolidBrush = new SolidBrush(this.dgvAccountBook.RowHeadersDefaultCellStyle.ForeColor);
6 int v_LineNo = 0;
7 v_LineNo = e.RowIndex + 1;
8
9 string v_Line = v_LineNo.ToString();
10
11 e.Graphics.DrawString(v_Line, e.InheritedRowStyle.Font, v_SolidBrush, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + 5);
12
13 }
14 catch (Exception ex)
15 {
16 MessageBox.Show("添加行号时发生错误,错误信息:" + ex.Message, "操作失败");
17 }
18 }