MyUserControlClass - the UC class
userControlInstance - the instance in the form
MyUserControlClass_Click - the handler method for the Click event
System.Reflection.EventInfo UserControlEventInfo = (typeof(MyUserControlClass)).GetEvent("Click");
System.Reflection.MethodInfo removeMethod = UserControlEventInfo.GetRemoveMethod();
removeMethod.Invoke(userControlInstance,new Object[] {new System.EventHandler(userControlInstance.MyUserCont rolClass_Click)});
but for that I need to make public in MyUserControlClass the delegated method MyUserControlClass_Click because the isolation level make them invisible.
probably with a more complex invoke you won't need this.
--
Horatiu Ripa
"John Taylor" <j.*******@elsevier.com> wrote in message news:05****************************@phx.gbl...
How do I invalidate the click event of a sub classed
button from the parent class.
I've created a button usercontrol for my windows form, and
in the click event in the parent if got a confirmation
msgbox. If the user pressed 'cancel', I don't want
the 'click' event of the child control to fire.
Please help, I've sent 2 days on this now and my brain is
hurting.
I know its something to do with inheritance but can't work
out what.
please help
John