chain of responsibility

  • Thread starter Thread starter Jamie
  • Start date Start date
J

Jamie

Has anyone got a practical C# example of using the chain of responsibility
in Windows Forms?

For example, I have a button inside a container inside a TabPage, etc.

If I click on the button I want to send a notify event up through the
hierarchy.

Thanks,
Jamie.
 
Hi Jamie,

You can expose the event as a public method for each class participating in
the chain. I'd also recommend moving this method to a separate interface
each participant would implement. Each control will be obliged to either
perform some real action in this method or just to forward the call to its
parent, provided the parent control implements the notification interface.
The last control in the chain will also trigger this method upon a click or
a keystroke to link the chain to some UI event.
 
Back
Top