Hi.
My problem has not been solved 100%... In Form_Closing event i typed Application.Exit(); because i have 2 forms.
in Form_Closing event also i am asking 'Are you sure to exit the program'. When i click 'Yes' button, it doesn't repeat the question. But i click 'No', it is asking the question twice. Here are the codes.
Application.Exit(); if (kisiler != null){
if (MessageBox.Show("Programi kapatmak istiyor musunuz ?", "YSM Üye Takip Programi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes){
if (MessageBox.Show("Bilgilerinizi kaydetmek istiyor musunuz ?", "YSM Üye Takip Programi", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes){
Helper.SaveList("kisiler.dat", kisiler);}
}
else{
e.Cancel =
true;}
}
Thanks..
yusufPosted Jan 17, 2008, 3:50 PM
Firstl, Alan and Niradhip thanks for helping.
I have handled the problem by adding Application.Exit() code underForm1_FormClosed event and deleted the same code under Form1_FormClosing... i did nothing else, it did work !..
Niradhip ChakrabortyPosted Jan 17, 2008, 2:59 PM
Hi yusuf,in form closing or wherever u want to exit ur application use the following code.
private
void mnuExit_Click(object sender, System.EventArgs e){
DialogResult temp = MessageBox.Show("Are you sure,do you want to Exit?","Exit", MessageBoxButtons.OKCancel); if (temp == DialogResult.OK){
System.Windows.Forms.
Application.Exit();}
}
AlanPosted Jan 17, 2008, 11:37 AM
Hi yusuf,
At the moment you are calling Application.Exit() and then asking the user to confirm whether he or she wishes to exit or not. I'd have thought that you need to ask the question first and then only call Application.Exit() if the answer to the question is 'yes'.