Example how to add AutoIncrement and PrimaryKey DataColumn values to DataTable
VB.NET
Dim dt As DataTable = New DataTable
dt.Columns("ID").AutoIncrement = True
dt.Columns("ID").AutoIncrementSeed = 1
dt.Columns("ID").ReadOnly = True
dt.Columns.Add("Name", GetType(String))
Dim dr = dt.NewRow()
dr("Name") = "John"
dt.Rows.Add(dr)
dt.Rows.Add(dr)
DataGridView1.DataSource = dt
C#
C#
DataTable dt = new DataTable();
dt.Columns.Add("ID", typeof(int));
dt.PrimaryKey = new DataColumn[] { dt.Columns["ID"] };
dt.Columns["ID"].AutoIncrement = true;
dt.Columns["ID"].AutoIncrementSeed = 1;
dt.Columns["ID"].ReadOnly = true;
dt.Columns.Add("Name", typeof(string));
dynamic dr = dt.NewRow();
dr("Name") = "John";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr("Name") = "Dan";
dt.Rows.Add(dr);
DataGridView1.DataSource = dt;