There is C# Project (.NET CF) that uses OpenNETCF.IOC.(UI) library.
Actual situation: In Base Form OnKeyDown event is handled and custom event can be raised (for example if user ESC button pressed). This event can be handled in descendant forms.
After refactoring: Base Form is now container form. All descendant forms are now SmartParts. How should I now raise custom event from container form to SmartParts?
// Base form
private void BaseForm_KeyDown(object sender, KeyEventArgs e)
{
// Handle ESC button
if (e.KeyCode == Keys.Escape || e.KeyValue == SomeOtherESCCode)
{
this.ButtonESCClicked(sender, new EventArgs());
}
}
// Descendant form
private void frmMyForm_ButtonESCClicked(object sender, EventArgs e)
{
this.AutoValidate = AutoValidate.Disable;
...
}
I'm not sure I fully understand the question, but I'll try to answer. If you want to raise an event from a child class, but that event is defined in a base class, you should use a "helper" method in the base:
If you're trying to go the other way, having the parent notify the children, then it's more like this: