美文网首页
C# datagridview 前面加行号

C# datagridview 前面加行号

作者: a9b854aded01 | 来源:发表于2017-11-21 13:57 被阅读0次
image.png

事件:

this.View.DgvGra.RowPostPaint += new System.Windows.Forms.DataGridViewRowPostPaintEventHandler(DgvGradeInfoRowPostPaint);

方法

 private void DgvGradeInfoRowPostPaint(object sender, System.Windows.Forms.DataGridViewRowPostPaintEventArgs e)
        {
            System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(e.RowBounds.Location.X,
                e.RowBounds.Location.Y,
                this.View.DgvStorageInfo.RowHeadersWidth - 4,
                e.RowBounds.Height);

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

相关文章

网友评论

      本文标题:C# datagridview 前面加行号

      本文链接:https://www.haomeiwen.com/subject/wsfwvxtx.html