小弟相求……………………………………
怎样可以dataGridView的第一列中显示这一行是第几条记录?

解决方案 »

  1.   

    --给数据添加一个序号就ok了,先添加序号后绑定。--在数据库中取数据的时候添加也可以,例如select * from tablename
    --改成
    select row_number() over (order by id) as num,* from tablename请不要大量发重复贴,会被删除的。
      

  2.   

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