[C#]
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...
}
}
}
解决方案 »
- winfrom窗体中DataGridView点击某一行头该行进入编辑模式(C#)
- 新手问题,请问如何控制TEXTBOX只能输入中文吖?
- DataGridView小问题,请进
- SqlBulkCopy 无法访问目标表“NEWS_PRESS1”。
- 使用过 MAPISendMail 函数者请进,提建议者也有分
- PictureBox画图失焦点后图像消失---Why?
- 请问各位高手 C#怎样修改批量文件名
- .net新人,想问个问题
- c#调用MATLABdll文件
- 来看看MDI的问题!!!在线等待!!!(高手请进)
- 很简单的问题:关于confirm对话框
- 请问怎样去掉DataGrid的空白行?(不修改其只读属性)
例:
void fun1()
{
Form1 fm = new Form1();
fm.ShowDialog();
}
void fun()
{
fun1(); //以下是其它处理}