private void MainForm_FormClosing(object sender, FormClosingEventArgs b)
{
b.Cancel=true;
if(MessageBox.Show("确定要退出系统?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question,MessageBoxDefaultButton.Button1)==DialogResult.Yes)
{
b.Cancel=false;
}
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
switch(treeView1.SelectedNode.Name)
{
case "0":
FormClosingEventArgs b = new FormClosingEventArgs(CloseReason.None, true);
MainForm_FormClosing(sender, b);///问题在这个地方?????
break;//退出系统
}
}
MainForm_FormClosing()这个的函数能正常关闭窗体。
为什么treeView1_AfterSelect(object sender, TreeViewEventArgs e)中调用MainForm_FormClosing()关闭不了窗体。