private void SubjectForm_FormClosing(object sender, FormClosingEventArgs e) { if (NoSave) { DialogResult result = MessageBox.Show("Сохранить изменения?", "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { Subjects.Save(); } else if (result == DialogResult.No) { Subjects.Load(); } else { e.Cancel = true; } } }
private void SaveSubjectsButton_Click(object sender, EventArgs e) { Subjects.Save(); NoSave = false; subjectGridView.DataSource = Subjects.Items.ToList(); }