Search code examples
c#mditoolstrip

How to merge mdi parent child toolstrip?


How can i find toolstrip1 control on child form. This does not work:

    private void EUF_MdiChildActivate(object sender, EventArgs e)
    {
        ToolStripManager.Merge(this.ActiveMdiChild.Controls("toolStrip1"), toolStrip1);
    }

I get an error :

     Error  1   
     Non-invocable member 'System.Windows.Forms.Control.Controls' cannot be used like a method. 

Solution

  • This should work

    ToolStripManager.Merge((ToolStrip)this.ActiveMdiChild.Controls["toolStrip1"] , toolStrip1);
    

    I think you're from VB background which uses () syntax for Indexing where as c# uses []. And your code doesn't work because () is used for method call and compiler assumes you're trying to call a method which doesn't exist!