c#實現messsagebox對話方塊的彈出和對話方塊選擇的操作
阿新 • • 發佈:2019-02-13
//實現messsagebox對話方塊的彈出和對話方塊選擇的操作
private void 刪除全部ToolStripMenuItem_Click(object sender, EventArgs e)
{
//string str=string.Format("Are you sure to delete all files in {0}",path);
StringBuilder str = new StringBuilder();
str.Append("Are you sure to delete all files in"+path);
DialogResult dr = MessageBox.Show(str.ToString(), "Warning", MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if(dr==DialogResult.Yes)//注意是diagresult.yes而不是ok;
{
listBox1.Items.Clear();
}
else
{ }
}
private void 刪除全部ToolStripMenuItem_Click(object sender, EventArgs e)
{
//string str=string.Format("Are you sure to delete all files in {0}",path);
StringBuilder str = new StringBuilder();
str.Append("Are you sure to delete all files in"+path);
DialogResult dr = MessageBox.Show(str.ToString(), "Warning", MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if(dr==DialogResult.Yes)//注意是diagresult.yes而不是ok;
{
listBox1.Items.Clear();
}
else
{ }
}