0

i'm developing an aplication in Winforms C#, this is my problem I make a expandible menu to reuse in every of my forms but when I click the button I need to open a new form and close the parent form from a user control , but when I try to do it by calling my own function on the user control it sends a NullReferenceException

This is my function

public void abrirFormulario(Form formulario)
    {
        Form padre= this.FindForm();
        padre.Close();
        padre.Dispose();

        formulario.Show();
        formulario.Activate();
    }

And this is the button that calls this function (This button is located inside a panel)

private void btnOperadores_Click(object sender, EventArgs e)
    {
        Form operador = new frmControl_Operadores();
        abrirFormulario(operador);
    }

Hope you can help me

0 Answers0