form instance RRS feed

  • Question

  • I want to run a form and have it close immediately?

    There are calculations in the form i want done.

    thank you, jordan

    Tuesday, February 13, 2018 9:18 PM

All replies

  • You can close a form inside its code by calling this.Close(). The "this" bit is redundant, but usually left in to make it clear that the form is closing itself.

    But if I were you, I would seriously consider moving the calculations out of the form and into a separate class.

    Tuesday, February 13, 2018 10:34 PM
  • Hi Jordan,

    In fact I'm not very clear for your question, if you want to close a form or close the application, in addition to Ante, you can also refer to the following another methods:

            private void button1_Click(object sender, EventArgs e)
                this.Close();//close this form
            private void button2_Click(object sender, EventArgs e)
            private void button3_Click(object sender, EventArgs e)
            private void button4_Click(object sender, EventArgs e)
                Environment.Exit(0);//close the environment



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Wednesday, February 14, 2018 5:53 AM