Abstract Form Inheritance

0

I have a default Form, with a textbox , a search button, and a grid; as I intend to use it for several searches, I left an abstract search method () and at the same time the form as abstract ... When inheriting this form, implement in the child form the Search () method that normally works running, however this child form is not loaded by the visual studio designer and returns the following error:

  

The designer must make an instance of type 'FormSearch'2 [[FormForm   System.Retaguard.Model, Version = 1.0.0.0, Culture = neutral,   PublicKeyToken = null], but it can not because the type was declared   as abstract.

    
asked by anonymous 24.04.2017 / 01:22

1 answer

1

Do not declare the form as abstract because it must be instantiated!

Leave the method as:

public virtual void Pesquisar()
{
throw new NotImplementedException("Método pesquisar não foi implementado");
}

and the children:

public override void Pesquisar()
{
//implementação
}
    
24.04.2017 / 02:43