How to inherit a form in c#?

Asked

Viewed 95 times

0

I have an application with the form FormFuncionario. I wish to inherit all the features of this form for a second class, called ControlFuncionario, where it will be responsible for holding various events, and, including, access the database. I was taught that I should not leave the logic and the part of database directly in the layer GUI, so I created another call BLL and tried to apply the following code :

namespace BLL.Pessoal // Camada/Pasta que está localizada a classe
{
    class ControlFuncionario : GUI.FormFuncionario //Aponta erro

    {
    }
}

The error is as follows :

CS0012 C# The type 'Form' is defined in an Assembly that is not referenced. You must add a Reference to Assembly.

My question is how I inherit this form for a "common class" ...

  • creates an empty form first, then changes the : Form for : GUI.FormFuncionario

  • If the FormFuncionario is in the Project GUI and class ControlFuncionario is in the BLL project, vc have to add BLL GUI reference, to have access to content.

  • 2

    Are you sure to bring a GUI form as a reference to your BLL? The correct one would be the opposite. And in BLL provide all the methods necessary to run the form... Now your GUI is a Windows.Form... Tomorrow can be a MVC, Web.Api and etc... It would not make sense, right? Including your BLL should also not directly access the database...

1 answer

1


As the error says, the binary type Form are not referenced in the project containing the class ControlFuncionario.

Add to this project a reference to Assembly System.Windows.Forms.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.