DataGridView에의 추가 라인 번호

1  // DataGridView를 용 RowPostPaint 생성 방법 선택 
2  
. 3  
. 4  
. 5   개인  공극 dgvStudentList_RowPostPaint ( 개체 SENDER, DataGridViewRowPostPaintEventArgs E)
 . (6)          {
 . 7            DataGridViewStyle.DgvRowPostPaint ( 이 본 .dgvStudentList, E)
 . 8          }
 . 9  
(10)  
. (11)  
(12)가  
13 인  ///  <요약> 
14          /// DataGridView에 라인 번호 추가
 15          ///  </ 요약> 
16          ///  <PARAM NAME = "DGV"> </ PARAM> 
. 17          ///  <매개 변수 이름 = "E"> </ PARAM>을
18          공공  정적  무효 DgvRowPostPaint (된 DataGridView DGV, DataGridViewRowPostPaintEventArgs E)
 19          {
 20              시도 
21              {
 22                  // 添加行号
23                  SolidBrush v_SolidBrush = 새로운 SolidBrush (dgv.RowHeadersDefaultCellStyle.ForeColor)를;
24                  INT v_LineNo = 0 ;
25                  v_LineNo e.RowIndex = + 1 ;
26                   v_Line = v_LineNo.ToString ();
(27)                 (v_Line, e.InheritedRowStyle.Font, v_SolidBrush, e.RowBounds.Location.X e.Graphics.DrawString + 15 , + e.RowBounds.Location.Y . 5 ),
 28              }
 29              캐치 (예외를 EX)
 30              {
 31은                  메시지 박스는. 쇼 ( " : 행 번호를 추가 할 때 오류가 오류 메시지가 발생 " + ex.Message, " 동작 실패 " )
 32              }
 33          }

 

추천

출처www.cnblogs.com/leizhui/p/11505798.html