Visual Form Inheritance C #

0

I have created a base form with an appearance that I will use in all my system registration forms, done that, all the forms that I create for registers will inherit the base class.

By doing this, I came across the following problem.

Error when opening the desing of the Form class that is inheriting from my base class:

  

The designer could not be shown for this file because none of the classes in it can be created. The designer inspected the following classes in the file: FormTest --- The base class 'WindowsFormsApplication4.FormBase' could not be loaded. Verify that the assembly was referenced and that all the projects were created.

This problem I solved by taking the (Generic) of the form, but I needed that it had generic type, have any other exit to accomplish what I want to do?

[Classe Base]

public partial class FormBase<T> : Form
{
    public FormBase()
    {
        InitializeComponent();           
    }

    public Form SetForm { set { ucPanelTitulo1.SetForm = value; } }

    public string SetTituloForm { set { ucPanelTitulo1.SetTextTitulo = value; } }

    private void FormBase_Load(object sender, EventArgs e)
    {
        bindingSource1.DataSource = typeof(T);            
    }
}

[Classe Form Realizando a Herança da Classe Base]

public partial class FormTeste : FormBase<Pais> 
{
    public FormTeste() : base()
    {            
        InitializeComponent();

        base.SetForm = this;
        base.SetTituloForm = "Cadastro de Países";

        this.Width = base.Width;
        this.Height = base.Height;
    }      
}

    
asked by anonymous 02.06.2017 / 22:35

1 answer

0

I was able to solve the problem after a lot of research.

link

    
02.06.2017 / 23:59