Link to home
Start Free TrialLog in
Avatar of adamtrask
adamtrask

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of adamtrask
adamtrask

ASKER

Thank you James...  your solution will help me with a lot of similar problems that I had to create other workarounds to implement.