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.
C#.NET Programming

Avatar of undefined
Last Comment
adamtrask

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
AndyAinscow

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
adamtrask

ASKER
Thank you Andy
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck