Dear All ;
My application is going strange ...
before I was making the form border style = none then I create my own close button which will close the curent window and open and pass values to other form. and was working prefectly.. for example if I have form1 and I want to close it and open form2 and after finishing I want to open again form1 after closing form2...
My code was like that :
openform2(object sender, EventArgs e)
{
functions fn = new functions();
form2 ts = new form2();
ts.Text = " Welcome Mr." + fn.GetuserNameFromFile();
this.Hide();
ts.ShowDialog();
this.Close();
}
then I opens form2 and so on...
after that I make the formborderstyle = sizable then I want to catch the form close event without using my own button .. what I have done in the form2 is the following :
at the intialize function I have added this line :
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
and then I carete the function :
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
functions fn = new functions();
form1 f1 = new form1();
f1.Text = " Welcome Mr." + fn.GetuserNameFromFile();
this.Hide();
f1.ShowDialog();
this.Close();
this.Dispose();
}
so what happens now the form2 closed succesfully , but when I try to close the form1 after finishing my proccess so I click on close button it is hiding it and then showing it hidding and showing ... so it is not closing ...
how to kill the proccess I want to close the software...
help...
regards..