[英]MessageBox close another form
嗨,大家好,我按了是,就收到了味精药盒。它关闭了那个叫味精药盒的表格。
Set the DialogResault
property to None
for the button which its event handler open the MessageBox. 将其事件处理程序打开MessageBox的按钮的
DialogResault
属性设置为None
。
Good luck! 祝好运!
DialogResult result = MessageBox.Show("Click yes to close, otherwise click no.", "Message Box Test", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
Application.Exit();
}
Maybe you're assigning the result to the DialogResult
property of the parent form, (see http://msdn.microsoft.com/en-us/library/system.windows.forms.form.dialogresult.aspx ) and in particular from the remark section : 也许您正在将结果分配给父表单的
DialogResult
属性(请参阅http://msdn.microsoft.com/zh-cn/library/system.windows.forms.form.dialogresult.aspx ),尤其是从备注部分:
" If the form is displayed as a dialog box, setting this property with a value from the DialogResult enumeration sets the value of the dialog box result for the form, hides the modal dialog box, and returns control to the calling form."
“如果表单显示为对话框,请使用DialogResult枚举中的值设置此属性,以设置表单的对话框结果的值,隐藏模式对话框,并将控件返回给调用表单。”
Use: 使用:
if (MessageBox.Show(...) == DialogResult.Yes)
{
}
else
{
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.