习惯了VB6的灵活、简单,C#中还真的有一些不习惯。在C#中我创建了两个Form,分别是Form1Form2。我在Form1中添加了一个Button1,添加了如下代码:

    Form2 newForm = new Form2();

newForm.Show();

然后,我在Form2中添加了两个ButtonButton1Button2。我在Button1Click事件中添加了如下代码:

this.Close();

目的是关闭Form2

我在Button2Click事件中添加了如下代码:

this.ParentForm.Close();

这个我的本意是想关闭其父窗体,也就是Form1。但在执行到这条语句时却出现了如下的错误:

如何关闭父窗体?C#(已解决)
    这是为什么呢?如何才能关闭父窗体呢?希望高手不吝剔教。

相关文章:

  • 2021-09-01
  • 2021-10-13
  • 2021-09-13
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-24
  • 2021-10-26
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2021-11-07
相关资源
相似解决方案