首页 > 代码库 > datagridview 添加行号
datagridview 添加行号
//显示datagridview 行号
private void kryptonDataGridView_sublstsfc_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
{
System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(e.RowBounds.Location.X,
e.RowBounds.Location.Y,
kryptonDataGridView_sublstsfc.RowHeadersWidth - 4,
e.RowBounds.Height);
TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(),
kryptonDataGridView_sublstsfc.RowHeadersDefaultCellStyle.Font,
rectangle,
kryptonDataGridView_sublstsfc.RowHeadersDefaultCellStyle.ForeColor,
TextFormatFlags.VerticalCenter | TextFormatFlags.Right);
}
datagridview 添加行号