Search code examples
c#mdiparent

enable and disable menu items of mdiparent from loginform in c#


i have two form,home and login.On home there is menu called file and menu items like login,logout when i run the application login form will open and after login home page will open.menuitems on home form will enabled=true when login is successfully i click on logout menu this will enabled=false all menu other than login.When i click on login menu login form will open,after successfull login my home form menu should be enabled=true

So my problem is that i am not been able to enabled=true menu from my login form


Solution

  • Hope you are showing LoginForm as ShowDialog(), not MDI Child. And if your Login is successful you can set the dialog result to OK or Yes. And in the next statment you can enable / disable the menu items

    mnuLogin_Click()
    {
    FrmLogin frmLogin = new FrmLogin();
    if(frmLogin.ShowDialog() == DialogResult.OK)
    {
    //Enable menu here.
    }
    }
    

    Hope it works :)