Calling a method from a different form

Hi,

I have two 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.
I created the following public method on frmMessages:

public void ShowHideMenu()
        {
            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();

            }

I need help understanding why this code is not working. Thank you.
adamtraskAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jacques Bourgeois (James Burger)PresidentCommented:
You have to display a form for its controls to be visible, and Frm is not displayed.

A form does not show only by calling its constructor. You also need to implicitly set its visible property to true or call its Show method.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
adamtraskAuthor Commented:
Thank you James...  your solution will help me with a lot of similar problems that I had to create other workarounds to implement.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.