C# DataGridView 在最左侧显示行号方法

代码:

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

效果:

C# DataGridView 在最左侧显示行号方法

上一篇:SqlServer判断数据库、表、字段、存储过程、函数是否存在


下一篇:DMA(Data Migration Assistant)迁移SQLServer数据库