3

我在派生名为“PrinterForm 这是表单的代码”的表单时遇到问题:

public partial class PrinterForm : Form
{
    public PrinterForm()
    {
        InitializeComponent();
    }

    private void PrinterForm_Load(object sender, EventArgs e)
    {
        LoadSomething();
    }

    private void LoadSomething()
    {
        //Return a List<dynamic> of Dapper (query work fine!). The function is already used elsewhere so no problem here
        var list = new DapperRepository().GetAllOfSomething(); 
    }
}

这是子窗体的代码:

public partial class FormChildren : PrinterForm
{
    public FormChildren()
    {
        InitializeComponent();
    }
}

当我尝试访问FormChildren设计器时,会报告错误并且未显示。报告给我的错误如下:

System.Windows.Forms.Design.IEventHandlerService

尝试对LoadSomething功能进行评论可以正确显示设计器。

有什么问题?

4

2 回答 2

1

我认为您的问题出在LoadSomething功能上,您应该尝试设置一个条件,以便在您与设计师合作时不会执行它。

请参阅:在继承的表单上打开设计器时出错

于 2016-11-23T12:56:35.393 回答
0

我有同样的问题。我通过将 base() 添加到子表单构造函数来解决我的问题。

public partial class FormChildren : ParentForm
{
    public FormChildren() : base()
    {
        InitializeComponent();
    }
}
于 2021-01-23T13:22:12.163 回答