Пример #1
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeView         treeView = sender as TreeView;
            ListView         list     = new ListView();
            Project1Entities entities = new Project1Entities();
            var sem = entities.Seminars;
            var lek = entities.Lektors;

            listView1.Items.Clear();
            if (treeView1.SelectedNode.Text == "Seminars")
            {
                foreach (var item in lek)
                {
                    listView1.Items.Add(item.LektorName);
                }
            }
            foreach (var item in sem)
            {
                var semlek = entities.SeminarsAndLektors;
                if (treeView1.SelectedNode.Text == item.SeminarName)
                {
                    foreach (var itemn in semlek)
                    {
                        if (itemn.SeminarsId == item.Id)
                        {
                            listView1.Items.Add(itemn.LektorsName);
                        }
                    }
                }
            }
        }
Пример #2
0
        public void bindtreeview()
        {
            var              kor      = "Seminars";
            TreeNode         rootnode = new TreeNode(kor);
            Project1Entities data1    = new Project1Entities();
            var              child    = data1.Seminars;

            foreach (var item in child)
            {
                TreeNode childNode = new TreeNode(item.SeminarName);
                var      sal       = data1.SeminarsAndLektors;
                foreach (var itemn in sal)
                {
                    TreeNode childno = new TreeNode(itemn.LektorsName);
                    if (itemn.SeminarsId == item.Id)
                    {
                        childNode.Nodes.Add(childno);
                    }
                }
                rootnode.Nodes.Add(childNode);
            }
            treeView1.Nodes.Add(rootnode);
        }
Пример #3
0
 private void Form2_Load(object sender, EventArgs e)
 {
     project1 = new Project1Entities();
     lektorsBindingSource.DataSource  = project1.Lektors.ToList();
     seminarsBindingSource.DataSource = project1.Seminars.ToList();
 }