/// <summary>
/// 绘制行号
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
Rectangle rectangle = new Rectangle(e.RowBounds.Location.X,
e.RowBounds.Location.Y,
((System.Windows.Forms.DataGridView)sender).RowHeadersWidth - 4,
e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
((System.Windows.Forms.DataGridView)sender).RowHeadersDefaultCellStyle.Font,
rectangle,
((System.Windows.Forms.DataGridView)sender).RowHeadersDefaultCellStyle.ForeColor,
TextFormatFlags.VerticalCenter);
}
dataGridview绘制行号
最新推荐文章于 2023-07-16 22:39:40 发布