遗忘海岸

江湖程序员 -Feiph(LM战士)

导航

DataGridView相关代码

加行号:

        private void dgv_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
                //添加行号  
                var dgv = sender as DataGridView;
                SolidBrush v_SolidBrush = new SolidBrush(dgv.RowHeadersDefaultCellStyle.ForeColor);
                int v_LineNo = 0;
                v_LineNo = e.RowIndex + 1;
                string v_Line = v_LineNo.ToString();
                e.Graphics.DrawString(v_Line, e.InheritedRowStyle.Font, v_SolidBrush, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + 5);

        }
View Code

 

posted on 2013-07-09 13:37  遗忘海岸  阅读(222)  评论(0编辑  收藏  举报