1. 程式人生 > >WinForm messagebox 確定取消按鈕事件

WinForm messagebox 確定取消按鈕事件

private void button2_Click(object sender, EventArgs e)
        {           
            MessageBox.Show("ABC",MessageBoxButtons.OKCancel);
        }

if(DialogResult.OK==MessageBox.Show("ABC",MessageBoxButtons.OKCancel))
{
//點選了OK
}
else
{
//點選了Cancel
}