在应用MDI过程中发现,MDI的自窗体Load事件写Close报错。
 
未处理的“System.InvalidOperationException”类型的异常出现在 system.windows.forms.dll 中。
其他信息: 执行 CreateHandle() 时无法调用 Close()。
 
通过Google找到解决方案。
因为这个错误产生的比较特殊,所以就记录一下
 
private void Form1_Load(object sender, System.EventArgs e)
  {
  //条件判断
   if(1==1)
   {
    this.VisibleChanged +=new EventHandler(Form1_VisibleChanged);
   }
  }
 
private void Form1_VisibleChanged(object sender, System.EventArgs e)
  {
   MessageBox.Show("没有权限");
   this.Close();
  }

相关文章:

  • 2021-07-25
  • 2021-07-25
  • 2022-12-23
  • 2021-08-03
  • 2021-11-27
  • 2022-12-23
  • 2021-11-17
猜你喜欢
  • 2021-08-30
  • 2021-10-22
  • 2021-12-10
  • 2022-01-26
  • 2022-12-23
  • 2022-01-02
  • 2021-08-05
相关资源
相似解决方案