将关键字 'this' 传递给 child 表单时不可用

Keyword 'this' is not available when passing it to child form

我有三种形式,其中一种是 parent,另两种是 children。我这样做的原因是 parent 形式可以引用 children,反之亦然(我实际上 运行 在这样做之前陷入无限递归错误,但一切都消失了) .

我写的代码如下:

public partial class PerfilAcesso : Form
{
 // this is the parent
     BDE bdeForm = new BDE(this); //error line
     Workshop workshopForm = new Workshop(this); //error line

// rest of the info
}


public partial class Workshop : Form
{
    // this is one child
    PerfilAcesso perfilAcesso;

    public Workshop(PerfilAcesso parent)
    {
        InitializeComponent();
        perfilAcesso = parent;
    }
}

public partial class BDE : Form
{
    // this is another child
    PerfilAcesso perfilAcesso;

    public BDE(PerfilAcesso parent)
    {
        InitializeComponent();
        perfilAcesso = parent;
    }
}

然而,它不会编译,因为它给出了以下错误

Keyword 'this' is not available in the current context

在第 4 行和第 5 行,我指出的地方。

我尝试将 parent 表单中的 属性 IsMdiContainer 设置为 true,但没有成功。

有人可以告诉我我做错了什么吗?我已经完成了有关创建 parent/child 表单的问题,它们都显示相同的内容。

this 在字段初始化中不可用。如果需要使用 this:

,则需要将初始化移至构造函数
public partial class PerfilAcesso : Form
{
     public PerfilAcesso () 
     {
        bdeForm = new BDE(this); 
        workshopForm = new Workshop(this); 
     }
     BDE bdeForm;
     Workshop workshopForm;
}