Link to home
Create AccountLog in
Avatar of adamtrask
adamtrask

asked on

switching the visibility of a menuStrip on a different form on and off

Hi,

I have two windows forms in a C# application. One called frmMessages and the second frmAdmin.

On the frmMessage form I have a menu called moveToToolStripMenuItem, which I need to make invisible from frmAdmin.

That was achieved using the code below. However, another problem crept up. Every time  frmMessage is re-loaded the menuStrip is
back to its original position. So, what I really need is to keep the strip invisible until switched to visible and, when switched to visible, stays visible until switched to invisible.

I created the following public method  on frmMessages:

public void ShowHideMenu()
        {
             this.Visible = true;
            ToolStripMenuItem item = new ToolStripMenuItem();
            item = this.moveToToolStripMenuItem;
           
            if (item.Visible == true)
            {
                item.Visible = false;
            }
           
        }

In frmAdmin I created a button that calls the above method:

 private void button1_Click(object sender, EventArgs e)
            {
             
                frmMessage Frm = new frmMessage();
                Frm.ShowHideMenu();

            }

Please advise. Thank you.
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of adamtrask
adamtrask

ASKER

Thank you Andy