private void DeleteFromGroupButtonClick(object sender, RoutedEventArgs e) { try { Student student = new Student (this.GroupStudentList[this.GroupStudentListView.SelectedIndex].Name, this.GroupStudentList[this.GroupStudentListView.SelectedIndex].LastName, this.GroupStudentList[this.GroupStudentListView.SelectedIndex].Bid, this.GroupStudentList[this.GroupStudentListView.SelectedIndex].PhoneNumber, this.GroupStudentList[this.GroupStudentListView.SelectedIndex].Adress, null); StudentList.Add(student); GroupStudentList.RemoveAt(this.GroupStudentListView.SelectedIndex); } catch (Exception) { MessageBox.Show("You have to select student from the list.", "Student not selected"); } }