private void cmbStore_SelectedIndexChanged(object sender, EventArgs e) { DataTable vDt = ParamClass.ChargDt; var q = from b in vDt.AsEnumerable() group b by new { storeid = b["STOREID"], charg = b["charg"] } into g select new { g.Key.storeid, g.Key.charg }; if (q != null && q.Count() > 0) { for (int i = 0; i < gridPurchaseOrderDetail.Rows.Count; i++) { (gridPurchaseOrderDetail.Rows[i].Cells["CHARG"] as DataGridViewComboBoxCell).DataSource = q.ToList(); (gridPurchaseOrderDetail.Rows[i].Cells["CHARG"] as DataGridViewComboBoxCell).ValueMember = "charg"; (gridPurchaseOrderDetail.Rows[i].Cells["CHARG"] as DataGridViewComboBoxCell).DisplayMember = "charg"; (gridPurchaseOrderDetail.Rows[i].Cells["CHARG"] as DataGridViewComboBoxCell).Value = q.ElementAt(0).charg; getStockNum(i); } } }
时间: 2024-11-06 12:43:41