首页 > Windows开发 > 详细

DataGridView显示行号

时间:2014-03-18 12:03:56      阅读:653      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
//可以在DataGirdView的RowPostPaint事件中进行绘制。
//如:添加以下方法代码 

private void DrawRowIndex(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
               e.RowBounds.Location.Y,
               this.costomerDataGridView.RowHeadersWidth - 4,
               e.RowBounds.Height);

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

        }
//即可完成显示行号的功能。
bubuko.com,布布扣

DataGridView显示行号,布布扣,bubuko.com

DataGridView显示行号

原文:http://www.cnblogs.com/tiaoma888/p/3606283.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!