Hi,
IIRC, you only need to set the Enabled property on the containing menu and
the menu's items will inherit the value, so looping isn't required.
To invoke a delegate you need a reference to an instance of the delegate and
then you can call the Invoke method:
ChangeMainMenuDelegate method = new
ChangeMainMenuDelegate(ChangeMainMenuState);
method.Invoke(true);
or the preferred 2.0 syntax with inference, as Daniel mentioned:
ChangeMainMenuDelegate method = ChangeMainMenuState;
method.Invoke(true);
However, you don't need a delegate if its target is in scope. In that case,
just call the target method directly:
view.ChangeMainMenuState(true);
(assuming "view" is an instance of the class that defines the
ChangeMainMenuState method)
--
Dave Sexton
http://davesexton.com/blog
<Ab******@gmail.comwrote in message
news:11*********************@11g2000cwr.googlegrou ps.com...
>I created a mainmenu in the form class. I added the following code
public delegate void ChangeMainMenuDelegate(bool bState);
public void ChangeMainMenuState(bool bState)
{
for (int n = 0; n < mainmenu.menuitems.count; n++)
{
mainmenu.menuitems[n].Enabled = bState;
}
}
I want to call the delegate from another class (View class)
How do I do this?
Thanks