Is there a reason it *has* to be through a delegate?
A Label control already has an event you can subscribe to of "Click".
When your parent form creates child a, and child b, it can subscribe b to the Label.Click event of a control in a.
Otherwise, you define an event (and EventArguments) for each tool in your pallet. Then raise that event when it is clicked. Your other forms subscribe (or listen for) that event to be raised, then react accordingly.
Here's a sample of how I do my Help events to show a custom messagebox with helpful text. It's triggered much as you described: My someone clicking a label next to a control.
- #region HelpSystem events
-
public delegate void HelpSystemDelegate(object sender, HelpSystemEventArgs e);
-
public class HelpSystemEventArgs : EventArgs
-
{
-
private string szHelpMsg;
-
public string HelpMsg
-
{
-
get { return szHelpMsg; }
-
set { szHelpMsg = value; }
-
}
-
-
public HelpSystemEventArgs(string HelpMsg)
-
{
-
szHelpMsg = HelpMsg;
-
}
-
}
-
public event HelpSystemDelegate RaiseHelp;
-
#endregion
-
#region Control Help calls
-
private void lblWidget_Click(object sender, EventArgs e)
-
{
-
ShowHelp("This is the Widget control. It does Widgety things.");
-
}
-
void ShowHelp(string HelpMessage)
-
{
-
if (cboEvent.SelectedItem != null)
-
{
-
HelpSystemEventArgs args = new HelpSystemEventArgs(HelpMessage);
-
if (RaiseHelp != null) RaiseHelp(this, args);
-
}
-
}
-
-
Here you should see EventArgs for the event, the event itself, a delegate for it, a method that gets called with your label is clicked which calls the all-purpose "ShowHelp" method.