• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 308
  • Last Modified:

Calling a method from a different form


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();


I need help understanding why this code is not working. Thank you.
1 Solution
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.
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now