C# Close Form - Web for example, if you want to close a windows form when an action is performed there are two methods to do it. When a form is closed, all resources created within the object are released and the form is disposed. Use the formclosing event instead. Web the problem probably happens because your main method is creating the first form and waits for it to close. Web set the dialogresult property in windows forms to close form in c#. Informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed. If you cancel this event, the form remains opened. The closing event occurs as the form is being closed. Web to close a form, you just need to set the form's dialogresult property (to any value by dialogresult.none) in some event handler. Either make the main method create the second form or dont close the first one and just hide it + hide the taskbar icon.
Web the problem probably happens because your main method is creating the first form and waits for it to close. Use the environment.exit method to exit the application in c#. Web to close a form, you just need to set the form's dialogresult property (to any value by dialogresult.none) in some event handler. In program.cs, instaead of calling application.run(new yourform()); Web the closing event is obsolete starting with the.net framework 2.0; When it closes the main proceeds and reaches the end which result in your application shutdown. Pass an instnace of your custom context. Form2 nextform = new form2 (); Private cmdclose_click(object sender, eventargs e) { Use the formclosing event instead. When a form is closed, all resources created within the object are released and the form is disposed. Informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed. Web set the dialogresult property in windows forms to close form in c#. If you cancel this event, the form remains opened. Use the form.dispose() method to dispose form in c#. Use the form.hide() method to hide form in c#. //u can use below comment also //this.close(); 2.we can also hide form without closing it Either make the main method create the second form or dont close the first one and just hide it + hide the taskbar icon. The closing event occurs as the form is being closed.