Home > Net >  Why do I add FormClosing code in c # WINFORM form programs is an error
Why do I add FormClosing code in c # WINFORM form programs is an error

Time:09-25


1, I'm _click () to add this. FormClosing
 public _click () 
{
InitializeComponent();
Enclosing FormClosing +=new FormClosingEventHandler (Form1_FormClosing);
}


2, and then in FORM1. C, add close form event code

 private void Form1_FormClosing (object sender, FormClosingEventArgs e) 
{

}


But the Visual Studio 2017 error, why?

CodePudding user response:

Do you want to write Form1 - FormClosing the events in class, what is your current is directly in the namespace

CodePudding user response:

Are you directly put the method in the namespace, not in the class
  •  Tags:  
  • C#
  • Related