MessageBox的按钮? [英] MessageBox Buttons?

查看:165
本文介绍了MessageBox的按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么会说,如果在消息框是按钮是pressed做到这一点,这和其他的?在C#。


解决方案

  1. 您调用 MessageBox.Show 需要通过 MessageBoxButtons.YesNo 来获得<大骨节病>是 / <大骨节病>否键而不是<大骨节病>确定​​按钮。


  2. 与此相比,电话(这将阻止执行,直到对话框返回到) DialogResult.Yes ...


 如果(MessageBox.Show(你确定吗?,确认,MessageBoxButtons.YesNo,MessageBoxIcon.Question)== DialogResult.Yes)
{
    //用户点击是
}
其他
{
    //用户点击无
}

How would I say if the yes button on the messagebox was pressed do this,that and the other? In C#.

解决方案

  1. Your call to MessageBox.Show needs to pass MessageBoxButtons.YesNo to get the Yes/No buttons instead of the OK button.

  2. Compare the result of that call (which will block execution until the dialog returns) to DialogResult.Yes....

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

这篇关于MessageBox的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆