//可以在DataGirdView的RowPostPaint事件中进行绘制。 //如:添加以下方法代码 private void DrawRowIndex(object sender, DataGridViewRowPostPaintEventArgs e) { Rectangle rectangle = new Rectangle(e.RowBounds.Location.X, e.RowBounds.Location.Y, this.costomerDataGridView.RowHeadersWidth - 4, e.RowBounds.Height); TextRenderer.DrawText(e.Graphics, (e.RowIndex + 1).ToString(), this.costomerDataGridView.RowHeadersDefaultCellStyle.Font, rectangle, this.costomerDataGridView.RowHeadersDefaultCellStyle.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Right); } //即可完成显示行号的功能。