首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

让DataGridView展示行号

2012-08-26 
让DataGridView显示行号RowPostPaint属性:当发生所有单元格绘制之后,执行行级绘制时引发的事件。private vo

让DataGridView显示行号
RowPostPaint属性:当发生所有单元格绘制之后,执行行级绘制时引发的事件。

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

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


转载自:http://www.cnblogs.com/basicapp/archive/2006/10/07/522851.html

热点排行