/// <summary>
/// 为m_DataTable新增一自增列
/// </summary>
private void AddAutoIncrementComunm()
{
DataColumn col = new DataColumn(NewColumnName, typeof(System.Int32));
col.AutoIncrement = true;
col.AutoIncrementSeed = 1;
col.AutoIncrementStep = 1;
m_DataTable.Columns.Add(col);
//循环为新增列的每一行赋值
for (int i = 0; i < m_DataTable.Rows.Count; i++)
{
m_DataTable.Rows[i][NewColumnName] = i + 1;
}
}
转载于:https://www.cnblogs.com/dawei362/archive/2008/09/02/1281759.html