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..

AlanRank #669 · 3.6K reputationPosted Jan 17, 2008, 6:37 AM EST
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'.
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Jan 17, 2008, 9:59 AM EST
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();}
}
yusuf57 reputationPosted Jan 17, 2008, 10:50 AM EST
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 !..