It does not sound like a good design idea, but there are real cases when you need to do something similar. The problem is: the user control is not supposed to "know" anything about the form using it.
But the problem is simple: you could use some delegate method passed by the parent form to the control, so the control could call it. Better yet, it should be encapsulated using some even of the user control. This is how, for example:
public class MyUserControl : UserControl {
public MyUserControl() {
myButton.Click += () => {
if (MyButtonClicked != null)
MyButtonClicked.Invoke(myButton, new System.EventArgs);
}
}
public event System.EventHandler MyButtonClicked;
Button myButton;
}
The parent form using this control can initialize it and add some event handler to the invocation list of you
MyUserControl.MyButtonClicked
event instance. This way, the instance of
MyButtonClicked
will invoke this event not "knowing" what the delegates put in the invocation list really do; they belong to the parent control. This way, the behavior detail of the two control (parent form and your user control) are properly encapsulated and controls' internals are isolated.
By the way, this is a simple example pf the
inversion of control concept:
http://en.wikipedia.org/wiki/Inversion_of_control[
^].
—SA