zl程序教程

您现在的位置是:首页 >  后端

当前栏目

C# winform DataGridView显示行标数字

c#Winform 显示 数字 DataGridView
2023-09-14 08:57:06 时间
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);
        }