Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- namespace NoteBook1
- {
- public partial class Form1 : Form
- {
- private bool isFilePass = true;
- public Form1()
- {
- InitializeComponent();
- }
- private void newToolStripMenuItem_Click(object sender, EventArgs e)
- {
- if (isFilePass)
- richTextBox1.Text = string.Empty;
- else
- Close();
- }
- protected override void OnClosing(CancelEventArgs e)
- {
- SaveFileDialog saveAs = new SaveFileDialog();
- DialogResult dialogResult = MessageBox.Show("Do you want to save changes to file?", "My noteBook", MessageBoxButtons.YesNoCancel);
- if (DialogResult.Yes == dialogResult)
- {
- saveAs.ShowDialog();
- }
- else if (DialogResult.No == dialogResult)
- {
- Close();
- }
- else
- e.Cancel = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement