Reputation: 97
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.
Upvotes: 0
Views: 1768
Reputation: 73482
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!
Upvotes: 4
Reputation: 887479
Controls
isn't a function; it's a property that returns a type with an indexer.
You need to write Controls[...]
.
Upvotes: 1