private void toolStripButton2_Click(object sender, EventArgs e) { if (treeView1.SelectedNode == null) { MessageBox.Show("请选择一个节点", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { DialogResult result = MessageBox.Show("确定要删除此节点的所有内容吗?", "删除节点", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (result) { case DialogResult.Yes: TreeXML tx = new TreeXML(); tx.DeleXml(starpath + @"\List.xml", treeView1.SelectedNode.Text); treeView1.SelectedNode.Remove(); break; case DialogResult.No: break; case DialogResult.Cancel: break; } } }
private void toolStripButton2_Click(object sender, EventArgs e) //删除分组 { if (treeView1.SelectedNode == null) { MessageBox.Show("请选择一个节点", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { //添加一个人性化的判断,使得删除操作显得不那么草率 DialogResult dResult = MessageBox.Show("确定要删除此节点的所有内容吗?", "删除节点", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); switch (dResult) { case DialogResult.Yes: TreeXML TreXml = new TreeXML(); TreXml.DeleXml(starpath + @"\List.xml", treeView1.SelectedNode.Text); //节点都是在List.xml中删除 treeView1.SelectedNode.Remove(); //删除节点 break; case DialogResult.No: break; case DialogResult.Cancel: break; } } }