Closing a form during a constructor

前端 未结 9 2041
面向向阳花
面向向阳花 2020-12-01 11:59

Is it possible to close a form while the constructor is executing (or simply to stop it showing at this stage)?

I have the following code:

public par         


        
9条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-01 12:28

    Can you make MyFunc static? and then do something like:

    static void Main() 
    {             
        ... 
        if (MyForm.MyFunc())
        {
            Application.Run(new MyForm()); 
        }
    } 
    

    this would essentially give you the same control over whether the form is going to be constructed or not?

提交回复
热议问题