DataGridView绘制序号!

来源:互联网 发布:python heatmap 编辑:程序博客网 时间:2024/06/10 16:03
        private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)        {            System.Drawing.Rectangle rectangle = new System.Drawing.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);        }


原创粉丝点击