473,511 Members | 17,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I invalidate an Event

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

Jul 21 '05 #1
3 4636
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


Jul 21 '05 #2
Thank you!
Very much appreciated!
John
-----Original Message-----
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.MyUserControlClass_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

Jul 21 '05 #3
Can any of you C# ninjas convert the solution into vb?

If not cool, i'll go the msdn route.
Thamks again
John
-----Original Message-----
Thank you!
Very much appreciated!
John
-----Original Message-----
MyUserControlClass - the UC class
userControlInstance - the instance in the form
MyUserControlClass_Click - the handler method for theClick event

System.Reflection.EventInfo UserControlEventInfo = (typeof(MyUserControlClass)).GetEvent("Click");
System.Reflection.MethodInfo removeMethod =UserControlEventInfo.GetRemoveMethod();
removeMethod.Invoke(userControlInstance,new Object[]

{newSystem.EventHandler
(userControlInstance.MyUserControlClass_Click)} );


but for that I need to make public in MyUserControlClassthe delegated method MyUserControlClass_Click because

theisolation 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 brainis hurting.

I know its something to do with inheritance but can'twork out what.

please help
John

.

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
12254
by: Mark Johnson | last post by:
Using: VS 2003 NET C# for Framework and Framework Compact Trying : Moving a Card (Bitmap) as in Solitare (PC + WinCe) Version on OnMouseMove Problem : The affected drawing Area by Invalidate (or...
1
14089
by: Amy | last post by:
What's different between Controls method Refresh() and Invalidate(), Refresh() and Update()? Your help will be appreciated. Thanks.
3
7505
by: jerry chapman | last post by:
Based on a mouse click I change something on the screen. I then want to repaint the screen to show the change. When I tried to use .Invalidate in my mouse routine, I got a compilation error. ...
3
6184
by: Colin McGuire | last post by:
Hi, I am just learning "how-to" by reading some of the existing article solutions in this newsgroup. I happened to come across this one. Tom Spink knows what he is talking about and I am wondering...
17
8493
by: SamSpade | last post by:
picDocument is a picturebox When I do picDocument.Invalidate() the box paints. But if instead I do picDocument.Refresh() the box does not paint. What does Refresh do. I guessed it did an...
3
268
by: John Taylor | last post by:
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...
4
4617
by: grayaii | last post by:
Hi, I have a simple form that handles all its paint functionality like so: this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); And the entry point to this...
1
8165
by: radders | last post by:
Hi everyone, I've written a simple programme using Visual C++ that assigns the values of the mouse's coordinates to a set of variables each time the mouse is moved to a new position with a button...
0
3000
by: raylopez99 | last post by:
Hi, I'm getting into GDI+ Forms 2.0 graphics for C#3 using Visual Studio 2008. One thing I notice: the graphics are really slow and flicker on a Pentium IV, with 2 GB RAM, even with...
0
7356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.