private void tree_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode node = tree.SelectedNode; int level = node.Level; if (level == 0) { int id = int.Parse(node.Name); IEnumerable <MayTinh> mts = tblPhongMay.GetMayTinhByPhongMay(id); LoadMayTinhToListView(mts); } else if (level == 1) { int idphong = int.Parse(node.Parent.Name); PhongMay pm = getPhong(idphong); MayTinh mt = (MayTinh)node.Tag; IEnumerable <MayTinh> list = tblPhongMay.GetMayTinhByPhongMay(pm.id); LoadMayTinhToListView(list); FocusListView(mt); } }
private void LoadDataToTree(TablePhongMay tblPhongMay) { IEnumerable <PhongMay> list = tblPhongMay.GetAll(); foreach (PhongMay i in list) { TreeNode root = new TreeNode(i.ten); root.Name = i.id.ToString(); tree.Nodes.Add(root); IEnumerable <MayTinh> mts = tblPhongMay.GetMayTinhByPhongMay(i.id); LoadMayTinhToTree(root, mts); } }