object[] obj = new object[bom.Columns.Count];
for (int i = 0; i < bom.Rows.Count; i++)
{
bom.Rows[i].ItemArray.CopyTo(obj, 0);
top.Rows.Add(obj);
for (int i = 0; i < bom.Rows.Count; i++)
{
bom.Rows[i].ItemArray.CopyTo(obj, 0);
top.Rows.Add(obj);
}//两个相同结构的表合并
top.Merge(bom);//有时候发现格式会乱
//去掉重复的单元,返回一张新表.
DataTable new_dt = new DataTable();
string[] str = new string[] { dataGridView1.Columns[1].HeaderText }; //去除重复的字段
DataView dw = dt.DefaultView;
DataTable dt2 = dw.ToTable(true, str); //返回一张去除重复后的表
//找出datatlble中重复的数据 //Item 是指定列,FIL09024C16B0是这一列中出现重复的数据
DataView dw = dt.DefaultView;
dw.RowFilter = "Item like '%FIL09024C16B0%'"; //这种是模糊查询 // dw.RowFilter = "Item = 'ROHS_E6'"; //这种是精确查询
DataTable dt_temp = dw.ToTable();