MessageBox帮助

时间:2009-08-27 13:22:53

标签: .net messagebox

如何使用“是”和“否”按钮显示MessageBox?

3 个答案:

答案 0 :(得分:10)

MessageBox.Show("text", "caption", MessageBoxButtons.YesNo);

.NET / C#

答案 1 :(得分:4)

if (confirm("Did you want to know how to do it in Javascript?"))
{
    alert("You did? Great!");
}
else
{
    alert("No? Tag your question with the required language/environment!");
}

或者,

int result = MessageBox(
        NULL,
        (LPCWSTR)L"So, did you want a Win32 example?",
        (LPCWSTR)L"OK, the javascript one was flawed",
        MB_ICONQUESTION | MB_YESNO
    );

或者

 int result = AfxMessageBox("Do people still use MFC?", 
     MB_ICONQUESTION | MB_YESNO);

答案 2 :(得分:1)

if( MessageBox.Show("Are you sure?", "MessageTitle", MessageBoxButtons.YesNo) == DialogResult.Yes )
   MessageBox.Show("You clicked Yes.");
else
   MessageBox.Show("You clicked No.");