码迷,mamicode.com
首页 > Windows程序 > 详细

Winform 程序中DataGridView 控件添加行号

时间:2014-12-22 14:24:19      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:

 private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)     

    {            

   Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,                 e.RowBounds.Location.Y,     dataGridView1.RowHeadersWidth,                 e.RowBounds.Height);    

            TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),                 dataGridView1.RowHeadersDefaultCellStyle.Font,                 rectangle,                 dataGridView1.RowHeadersDefaultCellStyle.ForeColor,                 TextFormatFlags.VerticalCenter |             TextFormatFlags.Right);        

}

Winform 程序中DataGridView 控件添加行号

标签:

原文地址:http://www.cnblogs.com/xakml/p/RowNo.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!