473,670 Members | 2,434 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 4647
MyUserControlCl ass - the UC class
userControlInst ance - the instance in the form
MyUserControlCl ass_Click - the handler method for the Click event

System.Reflecti on.EventInfo UserControlEven tInfo = (typeof(MyUserC ontrolClass)).G etEvent("Click" );
System.Reflecti on.MethodInfo removeMethod = UserControlEven tInfo.GetRemove Method();
removeMethod.In voke(userContro lInstance,new Object[] {new System.EventHan dler(userContro lInstance.MyUse rControlClass_C lick)});
but for that I need to make public in MyUserControlCl ass the delegated method MyUserControlCl ass_Click because the isolation level make them invisible.
probably with a more complex invoke you won't need this.

--
Horatiu Ripa

"John Taylor" <j.*******@else vier.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-----
MyUserControlC lass - the UC class
userControlIns tance - the instance in the form
MyUserControlC lass_Click - the handler method for the Click event
System.Reflect ion.EventInfo UserControlEven tInfo = (typeof (MyUserControlC lass)).GetEvent ("Click");System.Reflect ion.MethodInfo removeMethod = UserControlEven tInfo.GetRemove Method();removeMethod.I nvoke(userContr olInstance,new Object[] {new System.EventHan dler
(userControlIns tance.MyUserCon trolClass_Click )});

but for that I need to make public in MyUserControlCl ass the delegated method MyUserControlCl ass_Click because the
isolation level make them invisible.probably with a more complex invoke you won't need this.

--
Horatiu Ripa

"John Taylor" <j.*******@else vier.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-----
MyUserControl Class - the UC class
userControlIn stance - the instance in the form
MyUserControl Class_Click - the handler method for theClick event

System.Reflec tion.EventInfo UserControlEven tInfo = (typeof(MyUserControl Class)).GetEven t("Click");
System.Reflec tion.MethodInfo removeMethod =UserControlEve ntInfo.GetRemov eMethod();
removeMethod. Invoke(userCont rolInstance,new Object[]

{newSystem.EventHa ndler
(userControlIn stance.MyUserCo ntrolClass_Clic k)});


but for that I need to make public in MyUserControlCl assthe delegated method MyUserControlCl ass_Click because

theisolation level make them invisible.
probably with a more complex invoke you won't need this.

--
Horatiu Ripa

"John Taylor" <j.*******@else vier.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
12275
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 Invalidate(Rectangle)) flickers in a nasty way when repainting. This does not happen in the Solitare (PC + WinCe) Versions a well as in a Card game where I have the C++ Source. The use of an empty OnPaintBackground brings no visable results.
1
14118
by: Amy | last post by:
What's different between Controls method Refresh() and Invalidate(), Refresh() and Update()? Your help will be appreciated. Thanks.
3
7520
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. Here is my OnPaint code: protected override void OnPaint( PaintEventArgs paintEvent ) { Graphics g = paintEvent.Graphics;
3
6190
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 why he has done something. My question is how does this work <pseudo> Function To Override OnPaint(...) Call Base Class OnPaint(...)
17
8515
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 Invalidate and an Update. Can someone shed some light?
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 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.
4
4631
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 program is like so: static void Main() {
1
8179
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 pressed. It then draws a line between the new cursor position and the position stored in the variables, allowing you to sketch with the mouse. What I would like to do is assign a function to repaint the dialogue box to its initial setting (i.e. only...
0
3015
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 doublebuffering turned on. I did learn tricks such as not invalidating everything, but just the control that is part of the form you are working on (i.e.,
0
8471
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8386
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8903
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8815
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8661
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7421
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6216
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4393
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.