五道黑的博客
asp.net c# 之路
可以在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);

        }
即可完成显示行号的功能。

posted on 2007-06-16 13:55  五道黑  阅读(399)  评论(0编辑  收藏  举报