In this slightly contrived (though small, complete and perfectly formed)
example:
public class Inner
{
public event EventHandler InnerHandler;
public void DoSomething()
{
if ( InnerHandler != null )
InnerHandler( this, EventArgs.Empty );
}
public Inner()
{
}
}
public class Outer
{
private Inner _Inner = new Inner();
public event EventHandler OuterHandler;
public Outer()
{
_Inner.InnerHandler += new EventHandler( _Inner_InnerHandler );
}
private void _Inner_InnerHandler( object sender, EventArgs e )
{
if ( OuterHandler != null )
OuterHandler( this, EventArgs.Empty );
}
public void Test()
{
_Inner.DoSomething();
}
}
calling Outer.Test() calls the inner eventhandler which calls the outer
eventhandler. Is there any way to do this without the intermediate step - to
set up InnerHandler to call a delegate in my main form without having to
bubble it out through a chain of event handlers?
Thanks,
Andrew