if(application.exit()) checksave; 这个不对。请指教。
6 个解决方案
#1
你在窗体的form_Closeing事件里写:
protected void Form_Closeing(object sender,.....)
{
checksave();
...
}
#2
楼上说的对。
用Closing事件,这样更好
用Closing事件,这样更好
#3
你在窗体的form_Closeing事件里写:
protected void Form_Closeing(object sender,.....)
{
checksave();
...
}
protected void Form_Closeing(object sender,.....)
{
checksave();
...
}
#4
改写主窗体中的
protected override void Dispose( bool disposing )
{
if( disposing )
{
checksave();
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
checksave();
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#5
我也查到一个例子,不知道放哪里
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// Determine if text has changed in the textbox by comparing to original text.
if (textBox1.Text != strMyOriginalText)
{
// Display a MsgBox asking the user to save changes or abort.
if(MessageBox.Show("Do you want to save changes to your text?", "My Application",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
// Cancel the Closing event from closing the form.
e.Cancel = true;
// Call method to save file...
}
}
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// Determine if text has changed in the textbox by comparing to original text.
if (textBox1.Text != strMyOriginalText)
{
// Display a MsgBox asking the user to save changes or abort.
if(MessageBox.Show("Do you want to save changes to your text?", "My Application",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
// Cancel the Closing event from closing the form.
e.Cancel = true;
// Call method to save file...
}
}
}
#6
Using directives
namespace WindowsApplication5
{
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{}
}
static class Program
{
static void Main()
{
Application.EnableVisualStyles();
Application.EnableRTLMirroring();
Application.Run(new Form1());
}
}
}
加入不执行
namespace WindowsApplication5
{
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{}
}
static class Program
{
static void Main()
{
Application.EnableVisualStyles();
Application.EnableRTLMirroring();
Application.Run(new Form1());
}
}
}
加入不执行
#1
你在窗体的form_Closeing事件里写:
protected void Form_Closeing(object sender,.....)
{
checksave();
...
}
#2
楼上说的对。
用Closing事件,这样更好
用Closing事件,这样更好
#3
你在窗体的form_Closeing事件里写:
protected void Form_Closeing(object sender,.....)
{
checksave();
...
}
protected void Form_Closeing(object sender,.....)
{
checksave();
...
}
#4
改写主窗体中的
protected override void Dispose( bool disposing )
{
if( disposing )
{
checksave();
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
checksave();
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#5
我也查到一个例子,不知道放哪里
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// Determine if text has changed in the textbox by comparing to original text.
if (textBox1.Text != strMyOriginalText)
{
// Display a MsgBox asking the user to save changes or abort.
if(MessageBox.Show("Do you want to save changes to your text?", "My Application",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
// Cancel the Closing event from closing the form.
e.Cancel = true;
// Call method to save file...
}
}
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
// Determine if text has changed in the textbox by comparing to original text.
if (textBox1.Text != strMyOriginalText)
{
// Display a MsgBox asking the user to save changes or abort.
if(MessageBox.Show("Do you want to save changes to your text?", "My Application",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
// Cancel the Closing event from closing the form.
e.Cancel = true;
// Call method to save file...
}
}
}
#6
Using directives
namespace WindowsApplication5
{
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{}
}
static class Program
{
static void Main()
{
Application.EnableVisualStyles();
Application.EnableRTLMirroring();
Application.Run(new Form1());
}
}
}
加入不执行
namespace WindowsApplication5
{
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{}
}
static class Program
{
static void Main()
{
Application.EnableVisualStyles();
Application.EnableRTLMirroring();
Application.Run(new Form1());
}
}
}
加入不执行