/// <summary>
        /// 是DataGridView显示行号
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgReport_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            Bn6.Common.Utils.PointRowNumber(this.dgReport,e);
        }

/// <summary>
        /// 给DataGridView控件画行号
        /// </summary>
        /// <param name="dgv"></param>
        /// <param name="e"></param>
        public static void PointRowNumber(DataGridView dgv, DataGridViewRowPostPaintEventArgs e)
        {
            Rectangle rectangle = new Rectangle(e.RowBounds.X, e.RowBounds.Y,
                dgv.RowHeadersWidth - 4, e.RowBounds.Height);

            //参数  1.画笔   2.行号   3.字体样式   4.画笔位置   5.字体颜色  6.字体显示位置
            TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
                dgv.RowHeadersDefaultCellStyle.Font, rectangle,
                Color.Green,
                TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter);
        }

posted on 2012-06-06 11:42  清风暮雨  阅读(151)  评论(0)    收藏  举报