Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

event handler for form closing in c#

Status
Not open for further replies.

john1a98

Newbie level 3
Newbie level 3
Joined
Oct 27, 2013
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
18
Hi,

I am new to c#. I am writing code to event handler when windowsform is closed

My code:

Code:
private void CANToolFormClosing(object sender, CancelEventArgs e)
        {
            DialogResult dr = MessageBox.Show("Do you want to exit from the application?", "Are you Sure???", MessageBoxButtons.YesNo, MessageBoxIcon.Question);


            if (dr == DialogResult.No)
                e.Cancel = true;
        }

I do not understand why this code is not working.

Thanks in advance
John
 

What should happen?


Code - [expand]
1
2
3
4
5
6
7
8
private void button1_Click(object sender, EventArgs e)
{
            DialogResult dr = MessageBox.Show("Do you want to exit from the application?", "Are you Sure???", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
 
            if (dr == DialogResult.Yes)
                this.Close();
                        
}

 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top