DataGridView 显示行数
private void dataGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { try { DataGridView dgv = sender as DataGridView; Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, dgv.RowHeadersWidth - 4, e.RowBounds.Height); TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), dgv.RowHeadersDefaultCellStyle.Font, rectangle, dgv.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right); } catch (Exception ex) { } }