Close form when click X symbol [Resolved]

Posted by Jitenkumar under C# on 5/30/2013 | Points: 10 | Views : 1346 | Status : [Member] | Replies : 1
When clicked the X symbol of the form then a pop up will appear showing yes and no. If yes is clicked then form will close and when no is click form remains as it is.




Responses

Posted by: Satyapriyanayak on: 5/30/2013 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
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;
}
}
}
}


If this post helps you mark it as answer
Thanks

Jitenkumar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response