private void lecturers_list_box_SelectedIndexChanged(object sender, EventArgs e) { if (this.lecturers_list_box.SelectedItem != null) { List <Course> lC = new List <Course>(); courses_list_box.Visible = true; courses_list_box.Items.Clear(); lC = SqlWorker.GetStudentCourses((StaffMemeber)lecturers_list_box.SelectedItem); foreach (Course c in lC) { courses_list_box.Items.Add(c); } course_name.Text = ""; course_ID.Text = ""; course_Lecturer.Text = ""; course_type.Text = ""; have_pract.Text = ""; have_lab.Text = ""; } else { courses_list_box.Items.Clear(); courses_list_box.Visible = false; } }