C# MessageBox dialog result

前端 未结 5 1240
心在旅途
心在旅途 2021-01-30 04:17

I want to make a MessageBox confirmation. Here is the message box:

MessageBox.Show(\"Do you want to save changes?\", \"Confirmation\", messageBoxButtons.YesNoCan         


        
5条回答
  •  庸人自扰
    2021-01-30 04:35

    You can also do it in one row:

    if (MessageBox.Show("Text", "Title", MessageBoxButtons.YesNo) == DialogResult.Yes)
    

    And if you want to show a messagebox on top:

    if (MessageBox.Show(new Form() { TopMost = true }, "Text", "Text", MessageBoxButtons.YesNo) == DialogResult.Yes)
    

提交回复
热议问题