//绑定树节点及其子节点的方法
        private void bindTreeView()
        {
            this.treeView1.Nodes.Clear();
            //获取年级信息
            List<Grade> grades = dal.GetAll();
			//遍历填充年级信息
            foreach (Grade g in grades)
            {
                TreeNode gNode = this.treeView1.Nodes.Add(g.Name);
                gNode.Tag = g;
                //右键菜单
                gNode.ContextMenuStrip = this.contextMenuStrip1;
				//根据id显示对应的班级
                var gclasses = cdal.GetClassesByGradeId(g.ID);
				//遍历填充班级信息
                foreach (Classes cla in gclasses)
                {
                    TreeNode cnode = gNode.Nodes.Add(cla.CName);
                    cnode.Tag = cla;
                    cnode.ContextMenuStrip = contextMenuStrip2;
                }
            }
        }
posted on 2019-10-20 20:18  .net之路  阅读(223)  评论(0编辑  收藏  举报