1 //冻结将自增长列 2 this.DataGridView.Columns[0].Frozen = true; 3 4 private void DataGridView_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) 5 { 6 SolidBrush b = new SolidBrush(this.DataGridView.RowHeadersDefaultCellStyle.ForeColor); 7 e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), this.DataGridView.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 50, e.RowBounds.Location.Y + 4); 8 }