hi everyone, could anyone tell me how can i change my menustrip from menustrip1 to menustrip2. Well i have 2 forms, Form1 and Form2, in Form1 i have 2 menustrips menu1 & menu2. Once i click menu1, my form2 will show with a listview, so my form1 and form2 now is in display, and now what i want to happen is when i click an item in listview in form2, my menustrip in form1 will change from menu1 to menu2, but whats happening to my form is it does change from menu1 to menu2, but my problem is my form1 must change from enable to disable before it changes its menu. how can i do this without changing the form1 status, like it was always ENABLE. thank you for your replies...

heres my code:

FORM1(2 menustrip menu1 & menu2)
private void Form1_Load(object sender, EventArgs e)
      {
            menuStrip1.Show();
            menuStrip2.Hide();
      }

private void hiToolStripMenuItem_Click(object sender, EventArgs e)
        {
           this.Enabled = false;
           Form2 form2 = new Form2();
           form2.InstanceRef = this;
           form2.Show();
        }

private void menuStrip1_EnabledChanged(object sender, EventArgs e)
        {
          menuStrip1.Hide();
          menuStrip2.Show();
        }

FORM2(listview)

 private void Form2_Load(object sender, EventArgs e)
        {
            listView1.View = View.List;
            listView1.Items.Add("1");
            listView1.Items.Add("2");
        }
private Form m_InstanceRef = null;
        public Form InstanceRef
        {
            get{return m_InstanceRef;}
            set{m_InstanceRef = value;}
        }

private void Form2_FormClosed(object sender, FormClosedEventArgs e)
        {
            InstanceRef.Enabled = true;
        }
private void listView1_Click(object sender, EventArgs e)
        {
            InstanceRef.Enabled = true;
         }

First, when you post code, use the "CODE" tags....

In Form1.cs, put the following code:

public void ToggleMenus()
{
    menuStrip2.Enabled = !menuStrip2.Enabled;
    menuStrip1.Enabled = !menuStrip1.Enabled;
    menuStrip1.Visible = !menuStrip1.Visible;
    menuStrip2.Visible = !menuStrip2.Visible;
}

In Form1_Load, put this code:

menuStrip1.Enabled = true;
menuStrip2.Enabled = false;
menuStrip2.Visible = false;

In Form2's listView1_Click method, put this:

m_InstanceRef.ToggleMenus();

See how that works for you.

thank you very much for the reply, but it is not working, it says "System.Windows.Forms.Form does not contain a definition for "ToggleMenus' and no extension method "ToggleMenus' (are you missing a using directive or assembly ref?).

In Form1.cs, put the following code:

public void ToggleMenus()
{
    menuStrip2.Enabled = !menuStrip2.Enabled;
    menuStrip1.Enabled = !menuStrip1.Enabled;
    menuStrip1.Visible = !menuStrip1.Visible;
    menuStrip2.Visible = !menuStrip2.Visible;
}

In Form1_Load, put this code:

menuStrip1.Enabled = true;
menuStrip2.Enabled = false;
menuStrip2.Visible = false;

In Form2's listView1_Click method, put this:

m_InstanceRef.ToggleMenus();

See how that works for you.

OK, sorry, one more change you need to make. In Form2, change this line:

private Form m_InstanceRef;

to:

private Form1 m_InstanceRef;

That will allow you to "see" the "ToggleMenus" method in Form1.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.