c# - 消息框按钮?

标签 c# button messagebox

如果按下消息框上的是按钮,我会怎么说呢?在 C# 中。

最佳答案

  1. 您对 MessageBox.Show 的调用需要传递 MessageBoxButtons.YesNo 才能获得 Yes/No 按钮而不是 OK 按钮。

  2. 将该调用的结果(它将阻止执行直到对话框返回)与 DialogResult.Yes....

  3. 进行比较
if (MessageBox.Show("Are you sure?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
    // user clicked yes
}
else
{
    // user clicked no
}

关于c# - 消息框按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5414270/

相关文章:

C# 系统.Windows.Forms.TreeView : Stop auto expand/collapse on double-click (and execute another handler)

c# - 键值对的有序列表?

android - 单击和双击android中的按钮

c# - winforms 中消息框内的下拉/选择

C++ MessageBox (Windows.h) - 它有什么作用,我怎样才能让它不可见(或等效)?

c# - XPath last() 无法正常工作

c# - VSTS - 在部署之前使应用程序离线

html - 在 div 中居中 <a> 标签

.net - Visual Basic 2012 中的按钮单击修饰符

c# - ASP.NET 的消息框对话框