Enable controls after logging in

Asked

Viewed 50 times

0

Hello...then I need a help

I need to make sure that after logging in, on the login screen when you click the confirm button, the fields of the Main MDI are enabled (menustrip), that is when the application is loaded, the form_load calls the login form to enter the username and password. after authenticated, this login screen closes and the main MDI enables the menus. important detail is that both are loaded together, the MDI form and the login form for the user to authenticate in the system.

    //Form Pai - MDI
    private void MDIPrincipal_Load(object sender, EventArgs e)
    {
        Login login = new Login();

        login.MdiParent = this;

        menuStrip1.Enabled = false;

        login.Show();
    }

    public void habilitarControlers(bool valor)
    {
        menuStrip1.Refresh();
        menuStrip1.Enabled = valor;

    }


    // Form Filho - Login
    public delegate void definirValortextoRechamada(bool valor);

    public definirValortextoRechamada definirValorTexto;

    MDIPrincipal pai;

    public Login()
    {
        InitializeComponent();

        pai = new MDIPrincipal();

        definirValorTexto += new definirValortextoRechamada(pai.habilitarControlers);

    }

    private void btnConfirmar_Click(object sender, EventArgs e)
    {

        definirValorTexto(true);

        Close();


    }

1 answer

-1

Good afternoon Leo Barbosa, from what I understand are two different formularies correct? Which one is about to start in Startup?

An attempt to be made is to put the main MDI as the main one in the startup and call the login screen with the hidden main MDI. After Login release, close the Login form and add a true Visible on the Main MDI.

Try this idea and return.

Hugs.

  • Dae Luiz, sorry for the delay in answering...I understood your logic but it is not the one I want to do...in the case of Forms must be loaded together, both the MDI and the login but the MDI menustrip must be disabled while the user authentication is not done.

  • Exactly, you will load both, but will only make the MDI visible after completing the steps in the Login form, but the MDI is the startup, so you will have to call the login after starting it. I think it’s an alternative. Got another logic? if yes I shared it with us. Hugs.

Browser other questions tagged

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