// 这是加入行号的代码 using (SolidBrush b = new SolidBrush(dataGridView1.RowHeadersDefaultCellStyle.ForeColor)) { e.Graphics.DrawString((Convert.ToInt32(e.RowIndex) + 1).ToString(System.Globalization.CultureInfo.CurrentCulture), e.InheritedRowStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4); } //这是了隔行换色的代码 this.dataGridView1.RowsDefaultCellStyle.BackColor = Color.FromArgb(255,255,255);//第一行 this.dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(160,199,250);//第二行 this.dataGridView1.GridColor = Color.FromArgb(128,128,128);//字段网格边框
行高的设置:
RowTemplate属性下的Height 属性。