public void refreshTeachers() { Teacher_Services lectService = new Teacher_Services(); List <Teacher> lecturerList = lectService.getTeachers(); // clear the listview before filling it again listViewTeachers.Items.Clear(); foreach (Teacher teacher in lecturerList) { ListViewItem item = new ListViewItem(teacher.Number.ToString()); item.SubItems.Add(teacher.Name); listViewTeachers.Items.Add(item); } }
public void refreshTeachers() { Teacher_Services teacherServices = new Teacher_Services(); List <Teacher> teachers = teacherServices.getTeachers(); teachersComboBox.Items.Clear(); foreach (Teacher teacher in teachers) { teachersComboBox.Items.Add(teacher); } if (teachersComboBox.Items.Count > 0) { teachersComboBox.SelectedIndex = 0; } }