windows form cancel load

  • Thread starter Thread starter marc parthoens
  • Start date Start date
M

marc parthoens

Hi,

I'm in C#.
I am trying to close a form in the form_load event.
this.close(); does not work.
Is there another way to do it (maybe cancel this event)
Can someone help me.

Thanks
 
Hi,

I'm in C#.
I am trying to close a form in the form_load event.
this.close(); does not work.
Is there another way to do it (maybe cancel this event)
Can someone help me.

Take the logic that determines that the form should not load out of form
load and execute it before you even create your form. Something like:

public static void Main()
{
if( code_is_okay_to_run )
{
Application.Run(new Form1());
}
else
{
Console.WriteLine("no way I'm opening that form!");
}
}
 
Back
Top