How do I exit the program from the main form's constructor
-
In the constructor of my main form, I do some checking. If it doesn't pass the check, I give a MessageBox then I want to quit the program. As I have the code now, I get an ObjectDisposeException. What is the proper way to quit the program? public Form1() { InitializeComponents(); if(.......){ .... .... this.Close(); } }
-
In the constructor of my main form, I do some checking. If it doesn't pass the check, I give a MessageBox then I want to quit the program. As I have the code now, I get an ObjectDisposeException. What is the proper way to quit the program? public Form1() { InitializeComponents(); if(.......){ .... .... this.Close(); } }
dino2094 wrote:
In the constructor of my main form, I do some checking. If it doesn't pass the check, I give a MessageBox then I want to quit the program. As I have the code now, I get an ObjectDisposeException. What is the proper way to quit the program?
Override
OnLoad
, and do the checking there. I had the same problem and it took me awhile to figure it out. -
dino2094 wrote:
In the constructor of my main form, I do some checking. If it doesn't pass the check, I give a MessageBox then I want to quit the program. As I have the code now, I get an ObjectDisposeException. What is the proper way to quit the program?
Override
OnLoad
, and do the checking there. I had the same problem and it took me awhile to figure it out. -
In the constructor of my main form, I do some checking. If it doesn't pass the check, I give a MessageBox then I want to quit the program. As I have the code now, I get an ObjectDisposeException. What is the proper way to quit the program? public Form1() { InitializeComponents(); if(.......){ .... .... this.Close(); } }
If it is for the main form would it be better to have the exit program logic in the void main() method of the program rather than of the form.
Regards, Thomas Stockwell Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. Visit my homepage Oracle Studios[^]