private void SemesterComboBox_SelectedIndexChanged(object sender, EventArgs e) { CourseComboBox.Items.Clear(); CourseComboBox.Text = ""; semester = this.SemesterComboBox.Text; SemesterRepository smr = new SemesterRepository(); if (smr.CheckIsRegistrationOpen(semester)) { this.CourseComboBox.Visible = true; this.SelectCourseLabel.Visible = true; this.DoneRegistrationBtn.Visible = true; CourseRepository cr = new CourseRepository(); List <Course> cList = cr.GetAllCourses(semester, ID); for (int i = 0; i < cList.Count; i++) { this.CourseComboBox.Items.Add(cList[i].Name + " " + cList[i].Section); } } else { this.CourseComboBox.Visible = false; this.SelectCourseLabel.Visible = false; this.DoneRegistrationBtn.Visible = false; MessageBox.Show("Registration for this semester is Closed", "Error"); } }