Search code examples
c#winformsinheritancewindows-forms-designerform-load

C# designer is not shown when Inheritance form


I have a problem in deriving a form called PrinterForm This is the code of the parent form:

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(); 
    }
}

And this is the code of the children form:

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

When I try to access the FormChildren designers an error is reported and is not shown. The error that is reported to me is the following:

System.Windows.Forms.Design.IEventHandlerService

Trying to comment on the LoadSomething function can correctly display the designer.

What's the problem?


Solution

  • I think you're problem is in the LoadSomething function, you should try to put a condition so it is not executed when you're working with the designer.

    See : Error when opening designer on inherited form