C# winform DataGridView显示行标数字

private void DgvKaoshi_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dgvKaoshi.RowHeadersWidth - 4, e.RowBounds.Height);
            TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), dgvKaoshi.RowHeadersDefaultCellStyle.Font,
                rectangle, dgvKaoshi.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
        }

 

posted @ 2022-02-22 16:39  龙骑科技  阅读(201)  评论(0)    收藏  举报