View Full Version : سوال: خروج از برنامه
meitti
دوشنبه 21 مرداد 1387, 22:16 عصر
سلام
اگه خواسته باشیم هنگام خروج از برنامه پیامی مبنی بر مطمئن بودن خروج از برنامه را بدهد چیکار باید کرد؟
jaza_sa
دوشنبه 21 مرداد 1387, 22:36 عصر
پیغامی رو که میخواید نشون بدید در رویدادهای FormClosing یا FormClosed قرار دهید .
hdv212
دوشنبه 21 مرداد 1387, 23:19 عصر
اگر در رویداد FormClosing این کار رو انجام بدید بهتره، چون حتی میتونید رویداد مورد نظر رو هم Cancel کنید.
e.Cancel = true;
Salar Ashgi
سه شنبه 22 مرداد 1387, 00:20 صبح
کد مورد نظر شما :
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
DialogResult result = MessageBox.Show("Do Really Want to Exit ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
this.Hide();
}
else if (result == DialogResult.No)
{
this.Show();
}
}
موفق و پیروز باشید !!!
Amir Oveisi
سه شنبه 22 مرداد 1387, 00:48 صبح
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
DialogResult result = MessageBox.Show("Do Really Want to Exit ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
this.Hide();
}
else if (result == DialogResult.No)
{
this.Show();
}
}
این اون چیزی نیست که ایشون خواستن
درست ترش اینه:
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult result = MessageBox.Show("Do Really Want to Exit ?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result != DialogResult.Yes)
{
e.Cancel=true;
}
}
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.