C++开发博客CSDN

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;

posted @ 2013-10-31 10:58  纳凉亭子  阅读(182)  评论(0编辑  收藏  举报