如何取消取消按钮或确定按钮单击 [英] How to cancel a cancel button or Ok button click
问题描述
这可能是一个愚蠢的问题。这应该是一件容易的事情,我认为我有它的工作,但它不是,我看了,寻找答案,一直无法找到它。
问题是我的表单有一个ok按钮和一个取消按钮。在某些情况下,当单击其中一个按钮时,我想显示一个消息框以确认操作。但是,无论我做什么,表格都是封闭的。我认为这可能有用:
This is probably a stupid question. It should be an easy thing to do and I thought I had it working but it is not and I have looked, and looked for an answer and been unable to find it.
The problem is I have a form that has an ok button and a cancel button. Under certain circumstances when one of the buttons is clicked I want to show a Messagebox to confirm the action. However, no matter what I do the form is closed. I thought this might work:
if ( DialogResult.Yes == MessageBox.show("Are you sure?","confirm",MessageBoxButtons.YesNo, MessageBoxIcon.Question)
{
this.close();
else
return;
但是,我是否使用 this.close()
或 this.show()
或返回或不是最终的结果是表格是关闭而不是左显示,用户有机会改变他们的选择。
感谢您的帮助,很抱歉问这样一个愚蠢的问题。
Henry
However, whether I use this.close()
or this.show()
or return or not the end result is that the form is closed rather than left showing with the user given a chance to change their selection.
Thanks for the help, sorry to ask such a silly question.
Henry
推荐答案
这不起作用。我看到我忘了说我在Visual Studio Express 2010中使用c#。
e没有取消属性。
Henry
That doesn't work. I see I forgot to say that I am using c# with Visual Studio express 2010.
e does not have a cancel property.
Henry
if ( DialogResult.Yes == MessageBox.show("Are you sure?","confirm",MessageBoxButtons.YesNo, MessageBoxIcon.Question)
{
e.Cancel=True;
}
else
{
e.Cancel=False;
return;
}
这篇关于如何取消取消按钮或确定按钮单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!