You can create a custom event on your usercontrol, which you invoke when this button on your UserControl has been pressed.
For instance, create a user-control with a custom event that is called 'ButtonAClicked'.
Then, in your form, you can hook up an event-handler for this event:
| | myUserControl.ButtonAClicked += new EventHandler ( .... ); |
In your user-control, you will need to write some code so that this event is raised when Button A has been clicked:
| | private void ButtonA_Click( object sender, EventArgs e ) { OnButtonAClick(sender, e); } |
The OnButtonAClick method just looks like this:
| | protected void OnButtonAClick( object sender, EventArgs e ) { if( ButtonAClicked != null ) { ButtonAClicked (sender, e); } } |
(Well, this OnButtonAClick method is not that safe / good, note that you should also check whether you'll need to invoke the delegate, or if you can just execute it).
http://fgheysels.blogspot.com |