//根据学院加载课程 private void LoadAllCourseBySpeciality() { //得到“专业”的id和名称的键值对 Dictionary <int, string> dictionary = bll_speciality.GetAllspecialityIdAndNameByDelFlag(0); tbClassInfo.Selecting -= tbClassInfo_Selecting; //清除tabpages之前要先卸载选项卡改变事件 tbClassInfo.TabPages.Clear(); //清除tabpage tbClassInfo.Selecting += tbClassInfo_Selecting; //重新注册事件 //生成tabpage foreach (int key in dictionary.Keys) { TabPage page = new TabPage(dictionary[key]); page.Tag = key; page.Controls.Add(CreatedgvCourse()); //加入datagridview tbClassInfo.TabPages.Add(page); } this.Text = tbClassInfo.TabPages[1].Controls.Count.ToString(); }
private void LoadAllSpecialityByDelFlag() { SpecialityBLL bll = new SpecialityBLL(); cbClassInfoSpeciality.DataSource = bll.GetAllspecialityIdAndNameByDelFlag(0).ToList(); cbClassInfoSpeciality.DisplayMember = "Value"; cbClassInfoSpeciality.ValueMember = "Key"; // cbClassInfoSpeciality.DataSource = bll.GetAllSpecialityByDelFlag(0); //cbClassInfoSpeciality.DisplayMember = "Name"; //cbClassInfoSpeciality.ValueMember = "Id"; }
private void frmAddCourse_Load(object sender, EventArgs e) { //160, 30 txtCourseName.AutoSize = false; txtRoomName.AutoSize = false; txtSemester.AutoSize = false; txtCourseName.Size = new Size(160, 30); txtRoomName.Size = new Size(160, 30); txtSemester.Size = new Size(160, 30); //加载专业 SpecialityBLL bll = new SpecialityBLL(); Dictionary <int, string> dictionary = bll.GetAllspecialityIdAndNameByDelFlag(0); cbSpeciality.DataSource = dictionary.ToList(); cbSpeciality.DisplayMember = "Value"; cbSpeciality.ValueMember = "Key"; }