I believe that many of my friends will always encounter various problems in daily programming. The solution to clicking the close button on the form does not close the process is that many friends think it is very difficult to learn.. net, the following is a brief introduction by Dana.
This problem is also caused by insufficient experience in developing the form project.
When developing a small tool, because there are multiple form forms, the redirection between multiple forms is as follows:Code:
Private void button#click (Object sender, eventargs e) {This. hide (); urllist form = new urllist (this. cbuserid. selecteditem. tostring (); form. show ();}
In this way, I click the close button on the urllist form. If I want to debug it again, I will report that the file "OBJ \ debug \ autopage.exe" cannot be copied to "bin \ debug \ autopage.exe ". The file "bin \ debug \ autopage.exe" is being used by another process. Therefore, this process cannot access this file. It is very troublesome to disable the process in the task manager before debugging. I guess it is because the above this. Hide () only hides the current window and does not close it. So when I close another window, this window is still not closed.
Solution: Close all application windows in the form formclosed event. The Code is as follows:
Protected virtual void main_formclosed (Object sender, formclosedeventargs e) {application. Exit ();}
Extended: when developing a project, whether it is a web project or a form project, it is best that all forms inherit the base class, so that many common functions can be implemented in the base class. For example, if the above Code has a base class, you don't need to process the formclosed event of each form. You just need to process the base class!