给datagridview中添加序号(在datagrid中添加、在sql中添加)

在datagridview中添加

 private void dgvSummary_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
              SolidBrush b = new SolidBrush(this.dgvSummary.RowHeadersDefaultCellStyle.ForeColor);
              e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), this.dgvSummary.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20,         e.RowBounds.Location.Y + 4);
        }

  

在sql中添加

ROW_NUMBER() OVER (ORDER BY p.manfac ASC) AS id,

  

 

posted @ 2020-06-17 14:43  猎人7号  阅读(276)  评论(0编辑  收藏  举报