private void btnConstructLevel_Click(object sender, EventArgs e) { Module mod; //MessageBox.Show("hiii"); ModuleView moduleView = new ModuleView(); if (moduleView.ShowDialog() == DialogResult.OK) { mod = moduleView.Module; this.Course.Levels.Single(x => x.LevelName == tabControl.SelectedTab.Name).Modules.Add(mod); ModuleUC mc = new ModuleUC(mod); tabControl.SelectedTab.Controls[0].Controls.Add(mc); mod.Level = tabControl.SelectedTab.Name; modules.Add(mod); //TabPage page=tabControl.TabPages["Level 1"]; //TabPage page = tabControl.TabPages["Level 4"]; //if (page != null) //{ // page.Controls[0].Controls.Add(mc); //} } }
private void GenerateUI(Course course) { foreach (var level in course.Levels) { TabPage page = new TabPage(level.LevelName); FlowLayoutPanel panel = new FlowLayoutPanel(); //panel.FlowDirection = FlowDirection.BottomUp; panel.AutoScroll = true; panel.Dock = DockStyle.Fill; //panel.BackColor = Color.LightBlue; page.Controls.Add(panel); page.Name = level.LevelName; tabControl.TabPages.Add(page); btnConstructLevel = new Button(); //btnConstructLevel.Location = new Point(20, 10); btnConstructLevel.Text = "+"; panel.Controls.Add(btnConstructLevel); btnConstructLevel.Click += new EventHandler(btnConstructLevel_Click); foreach (var module in level.Modules) { ModuleUC modUc = new ModuleUC(module); //modUc.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; panel.Controls.Add(modUc); } } TabPage tpage = new TabPage("Summary"); tpage.Controls.Add(new SummaryUC(course)); tabControl.TabPages.Add(tpage); var standign = course.Standing; }