private void FrmDiaglogCapMaTuDong_Load(object sender, EventArgs e) { foreach (var item in this.lstCapMaTheoDonVi) { UscCapMaTheoDonVi us = new UscCapMaTheoDonVi(item.maDonVi); us.Location = new System.Drawing.Point(1, x); us.AutoSize = true; us.Name = item.maDonVi; us.SetGiaTri(item.soBatDau, item.soLuong); this.GroupDanhSach.Controls.Add(us); x += 29; } }
private void btnLuuMaXN_Click(object sender, EventArgs e) { foreach (var control in this.GroupDanhSach.Controls) { try { UscCapMaTheoDonVi ctr = control as UscCapMaTheoDonVi; var ct = this.lstCapMaTheoDonVi.FirstOrDefault(p => p.maDonVi == ctr.Name); if (ct != null) { ct.soBatDau = ctr.maBD; } } catch { } } this.DialogResult = DialogResult.OK; }