博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

DataGridView 添加行号

Posted on 2015-05-01 17:40  快乐家++  阅读(286)  评论(0编辑  收藏  举报

 

 

 private void dataGridViewX1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            //DataGridViewX dgv = sender as DataGridViewX;
            //System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dgv.RowHeadersWidth - 4, e.RowBounds.Height);
            //TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), dgv.RowHeadersDefaultCellStyle.Font, rectangle, dgv.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
        }