How do I create a message box with “Yes”, “No” choices and a DialogResult?

前端 未结 11 1850
时光取名叫无心
时光取名叫无心 2020-11-28 00:40

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

11条回答
  •  粉色の甜心
    2020-11-28 01:18

    DialogResult dr = MessageBox.Show("Are you happy now?", 
                          "Mood Test", MessageBoxButtons.YesNo);
    switch(dr)
    {
       case DialogResult.Yes:
          break;
       case DialogResult.No:
          break;
    }
    

    MessageBox class is what you are looking for.

提交回复
热议问题