private void btnDelGroup_Click(object sender, EventArgs e) { DialogResult question = MessageBox.Show("Are you sure?", "All book list in for this author will be deleted!", MessageBoxButtons.YesNo); if (question == DialogResult.Yes) { //========================= Group-un silinmesi ==================================== // downcast edirik ve comboBoxda secilmish groupun ID nomresini groupID-ye veririk string groupID = ((GroupCombo)cmbDel.SelectedItem).Value; // GroupList-den secilmish qrupu ID-ye gore tapib veririk Group tipinde groupToDeleted-e // bir nov apcast olunur ki Group-un icinden lazim olana catsin Group groupToDeleted = GroupList.GetGroupById(groupID); // GroupList-den Group classina girib Groups siyahisindan // ID-ci uyqun geleni silirik GroupList.Groups.Remove(groupToDeleted); //================================================================================== //=========== Silinen Group-un Student siyahisinin silinmesi =====================// // silinen group-un icindeki studentleri yeni List massivine yiqiriq List <Student> studentToBedeleted = StudentList.GetStudentsByGroup(groupToDeleted); // ve hemin massiv siralanir ve siyahidaki studentName-ler silinir foreach (Student studentName in studentToBedeleted) { StudentList.Students.Remove(studentName); } // Group-larin siyahisi yenilenir UpdateCombo(); } else { MessageBox.Show("You are cancelled deletion!"); } }