/// <summary> /// Ham de quy , add cac don vi vao tree view /// </summary> private void UpdateTreeVDonVi() { TreeV_QuocGiaTP.Nodes.Clear(); TreeNode newNode; TreeNode parentNode; for (int i = 0; i < lstQuocGia.Count; i++) { newNode = new TreeNode(); newNode.Name = lstQuocGia[i].ID.ToString(); newNode.Text = lstQuocGia[i].TenQuocGia; TreeV_QuocGiaTP.Nodes.Add(newNode); } for (int i = 0; i < lstQuocGia.Count; i++) { parentNode = TreeV_QuocGiaTP.Nodes[lstQuocGia[i].ID.ToString()]; List <Business.TinhTP> lstTPCon = lstTP.Where(a => a.QuocGiaID == Convert.ToInt32(parentNode.Name)).ToList(); for (int y = 0; y < lstTPCon.Count; y++) { newNode = new TreeNode(); newNode.Name = Convert.ToString(lstTPCon[y].ID); newNode.Text = lstTPCon[y].TenTinhTP; TreeV_QuocGiaTP.Nodes[lstQuocGia[i].ID.ToString()].Nodes.Add(newNode); } } TreeV_QuocGiaTP.ExpandAll(); }
private void QLNS_QuocGiaTP_Load(object sender, EventArgs e) { GetTinhTP_QuocGia(); if (lstQuocGia != null) { //JoinTinhTP_QuocGia(); UpdateTreeVDonVi(); TreeV_QuocGiaTP.ExpandAll(); FillQuocGiaCombo(); } comB_QuocGia.SelectedIndex = -1; }