我需要C#方面的帮助,我是.net编程的初学者. [英] I need help in c#, I am a beginner at .net programming.

查看:84
本文介绍了我需要C#方面的帮助,我是.net编程的初学者.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在c#中制作了两个表单,我希望不要通过单击十字按钮关闭第二个表单.我该怎么做?

解决方案

这将很好地工作:

 私有  void  Form2_FormClosing(对象发​​件人,FormClosingEventArgs e)
 {
     MessageBox.Show(" );
     e.Cancel =  true ;
 }



注意:
这不是主要的表单,因为在手动结束该过程之前,用户将无法结束您的应用程序.我看不到您不希望关闭表单的原因,您可以在决定是否取消事件arg之前确认用户是否真的要关闭表单


将表单的ControlBox属性设置为false.


将表单的ControlBox属性设置为false.


I have made two forms in c#, I want my second form not to be closed by clicking on the cross button. How can I do this?

解决方案

This will work just fine:

private void Form2_FormClosing(object sender, FormClosingEventArgs e)
 {
     MessageBox.Show("Sorry, you cannot close this form");
     e.Cancel = true;
 }



NOTE:
this should not be the main form as user will not be able to end your application until the manually end the process. I dont see a reason why you dont want a form to be closed, you can confirm if the user really want to close the form or not before deciding whether to cancel the event arg''s or not


Set the form''s ControlBox property to false.


Set the form''s ControlBox property to false.


这篇关于我需要C#方面的帮助,我是.net编程的初学者.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆