Saturday, 26 April 2014

How to Exit from this application



                                                                                                                                          Previous....
                                                                                                                                                  Next..

Here i will explain how to exit from this application.

Step(1):- Form

GO to form "Events"  there is a event "FormClosing" click on it
Step(2):- Code

Private void Form2_FormClosing(Object sender , FormClosing EventArgs e)
{
Application.Exit();
}

If you want to close your application at button click event write this code

private void btnclose_Click(object sender, EventArgs e) 
{
This.close();

If you want to that before closing a Pop Up show that you want to close this application or not then.

Private void Form2_FormClosing(Object sender , FormClosing EventArgs e)
{
DialogResult dialog = MessageBox.show("Do you want to close application", "Exit", MessageBoxButtons.YesNo);
if(dialog ==DialogResult.Yes)
{
Application.Exit();
}
elseIf(dialog ==DialogResult.No)
{
e.cancel= true;
}
}


Step(3):- Output
Now run your application and close this application as gracefully.
                                                                                                                                          Previous....
                                                                                                                                                  Next..

No comments:

Post a Comment

C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...