C# Tutorial 19: Message Box Asking if The User Wants To Exit

C# Tutorial 19:   Message Box Asking if The User Wants To Exit

ClickOnce creates defect runtime code‎ C sharp Message Box Asking Wether The User Wants To Save Before FormClosing and Application.Exit is causing the Messag…

Don’t forget to check out our other video tutorials or share this video with a friend.

1 Star2 Stars3 Stars4 Stars5 Stars 0 votes
Loading... 1,836 views





14 responses to “C# Tutorial 19: Message Box Asking if The User Wants To Exit”

  1. Luther Oplida says:

    The Problem is this code (dialog == DialogResult.Yes)

    Try this (dialog != DialogResult.Yes)

  2. GIDEON KIMATHI says:

    Application.ExitThread() works fine. 

  3. UMAR BASHIR says:

    Use it Application.ExitThead();

  4. Teboho Mokoena says:

    This is how you solve the issue

    DialogResult dialog = dialog = MessageBox.Show(“Do you really want to
    close the program?”, “SomeTitle”, MessageBoxButtons.YesNo);
    if (dialog == DialogResult.No)
    {
    e.Cancel = true;
    }

  5. Bang Lore says:

    THIS WORKS FOR ME,
    change this
    e.cancel = false;
    for returning value..
    🙂

    if (dialog == DialogResult.Yes)
    {
    e.Cancel = false;

    }
    else if (dialog == DialogResult.No)
    {
    e.Cancel = true;
    }

    I REALLY THANKING YOU SIR,
    IT WORKS FOR ME
    AS I M FOLLOWING YOUR TUTORIALS FROM THE BEGIN IT S VERY HELPFUL FOR ME TO
    LEARN EASILY, THANKING U ONCE AGAIN SIR.

  6. MrKambiwayne says:

    it really helps… thanks!

  7. ActivateD says:

    Thank you. ProgrammingKnowledge should take your response as it sorts out
    the program

  8. sandeepscs says:

    e.cancel is not available? what do do? e.CloseReason only?

  9. Junaid Safdar says:

    jst remove if for the application exit and use the cancel codes.which shown
    in video and its done.

  10. Wennie Sasotona says:

    yeah it really help

  11. Higson Santos says:

    It work

  12. regeseki says:

    Hello ProgrammingKnowledge, the one causing the problem is the code:
    Application.Exit(); You should use the code: Application.ExitThead(); hope
    it helps 🙂

  13. GudiyaSwweet says:

    that is becoz you generated(clicked) FormClosed event. Generate(click)
    FormClosing event. Both the events are different.

  14. kevin kastrowiak says:

    exciting ! ! thanks fella ! !

Leave a Reply

Your email address will not be published. Required fields are marked *