Close form when click X symbol

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;



namespace WindowsFormsApplication11

{

    public partial class Form5 : Form

    {

        public Form5()

        {

            InitializeComponent();

        }



        private void Form5_FormClosing(object sender, FormClosingEventArgs e)

        {

            if (MessageBox.Show("Do you want to Close the form?", "Form close", MessageBoxButtons.YesNo) == DialogResult.No)

            {

                e.Cancel = true;

            }

        }

    }

}
Ebook Download
View all
Learn
View all