Results 1 to 3 of 3

Thread: [RESOLVED] [2005] MDI and Childs problems

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2007
    Posts
    89

    Resolved [RESOLVED] [2005] MDI and Childs problems

    Hi,

    My English is not native, sorry.

    I have MDI form and Child form.
    I added "Form_Closing" event to the MDI code file. the following is the code:

    c# Code:
    1. private void frmMainMdi_FormClosing(object sender, FormClosingEventArgs e)
    2.         {
    3.             // Hold the MessageBox button pressed
    4.             DialogResult diaResult;
    5.             // Show Message to the User
    6.             diaResult = MessageBox.Show("Are you sure you want to cancel the setup?",
    7.                                         "Exit Setup",
    8.                                         MessageBoxButtons.YesNo,
    9.                                         MessageBoxIcon.Warning,
    10.                                         MessageBoxDefaultButton.Button2);
    11.            // Checking which button as been pressed
    12.            if (diaResult == DialogResult.No)
    13.            {
    14.                // CANCEL pressed, set focus to the program
    15.                e.Cancel = true;
    16.            }
    17.            else
    18.            {
    19.                // YES pressed, exit the program
    20.                this.Dispose();
    21.                Application.Exit();
    22.            }
    23.         }

    Now, in the child form i have CANCEL button that suppose to teminate the application if the user press YES.

    I added to the click event the following code:

    c# Code:
    1. private void btnCancel_Click(object sender, EventArgs e)
    2.         {
    3.           Application.Exit();
    4.         }

    And now I am having the problem,

    I am getting an error when I try to cancel the program and the error points to the cancel button, application.exit();
    the following is the VS2005 ERROR:

    System.InvalidOperationException was unhandled
    Message="Collection was modified; enumeration operation may not execute."
    Source="mscorlib"



    How can I terminate the program from runnning when pressing the cancel button?

    Thanks
    VBDC
    Last edited by vbdc; May 8th, 2007 at 07:14 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width