本文介绍了如何创建一个消息框,"是","否];选择和的DialogResult?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想进行简单的是/否choiced消息框,但我认为这是无稽之谈设计一个表格的。我以为我可以使用的MessageBox,添加按钮,等来做到这一点。这是简单的,但因为没有返回的DialogResult,我怎么检索结果?
I want to make simple Yes/No choiced MessageBox, but I think it is nonsense to design a form for that. I thought I could use MessageBox, add buttons, etc. to accomplish this. It is simple, but since there is no DialogResult returned, how do I retrieve the result?
推荐答案
这应该这样做:
DialogResult dialogResult = MessageBox.Show("Sure", "Some Title", MessageBoxButtons.YesNo);
if(dialogResult == DialogResult.Yes)
{
//do something
}
else if (dialogResult == DialogResult.No)
{
//do something else
}
这篇关于如何创建一个消息框,"是","否];选择和的DialogResult?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!