dataGridView怎么在第一行的ID,按添加键后自动加1

解决方案 »

  1.   

    如果是用sql,在数据库那里设置那一个标记为true 
      

  2.   

    #region[事件][行序列号实现]
            private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
            {
                if (e.ColumnIndex < 0 && e.RowIndex >= 0)
                {
                    e.Paint(e.ClipBounds, DataGridViewPaintParts.All);
                    Rectangle indexRect = e.CellBounds;
                    indexRect.Inflate(-2, -2);
                    TextRenderer.DrawText(e.Graphics,
                        (e.RowIndex + 1).ToString(),
                        e.CellStyle.Font,
                        indexRect,
                        e.CellStyle.ForeColor,
                        TextFormatFlags.Right | TextFormatFlags.VerticalCenter);
                    e.Handled = true;            }
            }
            #endregion
    看一下这个是不是你要的效果
      

  3.   


    可是我用的是ACCESS怎么办啊?加急哦!谢谢
      

  4.   

    对了,还有我是用C#编的~利用dataGridView显示内容了,但在第一行ID希望能按添加键后自动就能加1