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!");
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top