可以在C#的 MessageBox.Show()弹出框的按钮中添加动作吗?

2024-12-14 07:20:58
推荐回答(4个)
回答1:

这个不用再messagebox代码里加,而是在主窗体里加,假如说你用主窗体的button来调用messagebox,那么代码为:
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
if (MessageBox.Show("info", "test", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
{
this.Show();
}
}

回答2:

if (MessageBox.Show("") = DialogResult.OK)
Form1.Show();

回答3:

DialogResult dr = MessageBox.Show();
if (dr == DialogResult.OK)
{
this.WindowState = FormWindowState.Minimized;
}

回答4:

Form1 form=new Form();
private void button_click(object sender, EventArgs e)
{
form.Show();
}