我如何...通过询问用户是否关闭来关闭表单。

编程入门 行业动态 更新时间:2024-10-07 14:24:45
本文介绍了我如何...通过询问用户是否关闭来关闭表单。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

public ref class form3 : public System::Windows::Forms::Form { public: form3(void) { InitializeComponent(); timer1->Start(); // //TODO: Add the constructor code here // } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~form3() { if (components) { delete components; } } private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) { DateTime datetime = DateTime::Now; this->label1->Text=datetime.ToString(); } System::Void form3_FormClosing(System::Object^ sender, System::Windows::Forms::FormClosingEventArgs^ e) { if (MessageBox::Show("Do you Really Want to Exit?","Form3", MessageBoxButtons::YesNo,MessageBoxIcon::Question) == (System::Windows::Forms::DialogResult::Yes)) { timer1->Stop(); //i enabled timer //Application::Exit(); form3::Close(); } else { e->Cancel=true; } } }

在此代码中,当我单击表单上的X按钮时,它要求关闭或者没有,但即使我选择'是'选项,对话框也没有关闭。

Here in this code,When i click "X" button on form ,it is asking to close or not,but Even though i choose 'yes'option, dialog box is not closing.

推荐答案

你在这条线上设置了断点 Have you put a break point on this line if (MessageBox::Show("Do you Really Want to Exit?","Form3", ...

看你的代码是否被执行了? 你可以尝试改变

to see if your code is executed? You can try to change

form3::Close();

to

to

this->Close();

更多推荐

我如何...通过询问用户是否关闭来关闭表单。

本文发布于:2023-11-03 04:57:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554292.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   用户

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!