Close a form programmatically

  • Thread starter Thread starter Ben
  • Start date Start date
B

Ben

Greetings!

I am trying to close a form programmatically and I am
having trouble. The program is a windows form, however,
I also want to be able to run the program in an
unattended mode and then close down when it is down. I
collect the arguments from the command line and then I
want to be able to close the program after running those
function. Below is a snippet of the code I am using.....

I already tried to do this.close() and this.dispose().
They don't work.

Ben.


string [] args= Environment.GetCommandLineArgs();
bool Delete = false;
bool Update = false;
bool Insert = false;
string FC = "";
foreach (string a in args) //Run
Delete
{
if (a == "/d:Well")
{ Delete = true;
FC="Well";}
else if (a
== "/d:Outfall")
{ Delete = true;
FC="Outfall";}
else if (a
== "/u:Outfall")
{ Update = true;
FC="Outfall";}
else if (a == "/u:Well")
{ Update = true;
FC="Well";}
else if (a == "/i:Well")
{ Insert =
true;FC="Well";}
else if (a
== "/i:Outfall")
{ Insert =
true;FC="Outfall";}

}
if (Delete == true || Insert ==
true)
{
//
if (FC == "Well")
{ dWells(); uCmd();}
else if (FC == "Outfall")
{ dOutfalls();uCmd
();}
if (Insert == true)
{
if (FC == "Well")
{ aWells
();uCmd();}
else if (FC
== "Outfall")
{ aOutfalls
();uCmd();}}
}
else if (Update == true)
{if (FC == "Well")
{ uWells(); uCmd();}
else if (FC == "Outfall")
{ uOutfalls();uCmd();}}
 
the form won't close if you call Close() from within the
page init handler. I think Close() would work if you
called Close() from the page's contructor. So try moving
your code into the constructor and it should work.

Sergey
 
Back
Top