DataTable 的使用
DataTable CFHMXdt = new DataTable();
CFHMXdt.Columns.Add("group", typeof(System.String));
CFHMXdt.Columns.Add("XH", typeof(System.Int32));
CFHMXdt.Columns.Add("SPMC", typeof(System.String));
CFHMXdt.Columns.Add("SL", typeof(System.Decimal));
CFHMXdt.Columns.Add("DJ", typeof(System.Decimal));
CFHMXdt.Columns.Add("JE", typeof(System.Decimal));
DataRow cfhMXrow = CFHMXdt.NewRow();
cfhMXrow["group"] = String.Format("{0}_{1}", bill.BH, dgvSplit["group", i].Value);
cfhMXrow["XH"] = Convert.ToInt32(dgvSplit["XH", i].Value);
cfhMXrow["SPMC"] = dgvSplit["SPMC", i].Value;
cfhMXrow["SL"] = Convert.ToDouble(dgvSplit["SL", i].Value);
cfhMXrow["DJ"] = Convert.ToDouble(dgvSplit["DJ", i].Value);
cfhMXrow["JE"] = dgvSplit["JE", i].Value;
CFHMXdt.Rows.Add(cfhMXrow);
string BH = dgvAferBillHeader.Rows[e.RowIndex].Cells["BH"].Value.ToString();
CFHMXdt.DefaultView.RowFilter = "group ='" + BH + "'";
this.dgvAfterGoods.DataSource = CFHMXdt;