本文介绍了如何创建带有“是",“否"的消息框?选择和DialogResult?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想简单地选择是/否选择MessageBox,但是我认为为此设计表格是没有意义的.我以为可以使用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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 23:20