private void ShowErrorPanel(Exception ex) { ControlsVisible = new Dictionary <Control, bool>(); foreach (Control ctl in Controls) { ControlsVisible.Add(ctl, ctl.Visible); } foreach (Control ctl in Controls) { ctl.Visible = false; } string help = "很抱歉,目前資料項目已經炸掉!訊息如下:\r\n"; string msg = ErrorReport.Generate(ex); MsgPanel = new DetailContentImprovedMsg(); Controls.Add(MsgPanel); Controls.SetChildIndex(MsgPanel, 0); MsgPanel.Dock = DockStyle.Fill; MsgPanel.Message = help + msg; }