Last active
July 6, 2021 10:38
-
-
Save Mahno74/3462dbe4afcf7760efcb6b35edfb48ab to your computer and use it in GitHub Desktop.
Отработка сообщения Yes-No-Cancel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Form1_FormClosing(object sender, FormClosingEventArgs e) | |
{ | |
// Обработка момента закрытия формы | |
if (richTextBox1.Modified == false) return; | |
// Если текст модифицирован выясняем записывать ли файл | |
var MBox = MessageBox.Show("Текст был изменен\n" + "Сохранить изменения?", "Простой редактор", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation); | |
if (MBox == DialogResult.No) return; | |
if (MBox == DialogResult.Cancel) e.Cancel = true; | |
if (MBox == DialogResult.Yes) | |
{ | |
if (saveFileDialog1.ShowDialog() == DialogResult.OK) | |
{ | |
Запись(); | |
return; | |
} | |
else e.Cancel = true; //Передумал выходить | |
} // Конец условия DialogResult.Yes | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment