473,799 Members | 3,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VS.NET overwrites my event handlers

I'm working on a windows forms application and some of my controls have
multiple event handlers assigned to them. I haven't figured out how to add
multiple event handlers via the properties window, so I do it manually.
However, it seems that whenever I bring up a properties window, VS removes
one of my handlers, from each control that has more than one handler. Please
help!
How can I get this to stop??

--
Jaan
Aug 14 '06 #1
5 1948

jrett wrote:
I'm working on a windows forms application and some of my controls have
multiple event handlers assigned to them. I haven't figured out how to add
multiple event handlers via the properties window, so I do it manually.
However, it seems that whenever I bring up a properties window, VS removes
one of my handlers, from each control that has more than one handler. Please
help!
How can I get this to stop??

--
Jaan
Where abouts in your code are you writing the manual event handlers?

It should be done in the form's constructor, not in the windows
generated region.

Nick
http://seecharp.blogspot.com/

Aug 14 '06 #2

jrett wrote:
I'm working on a windows forms application and some of my controls have
multiple event handlers assigned to them. I haven't figured out how to add
multiple event handlers via the properties window, so I do it manually.
However, it seems that whenever I bring up a properties window, VS removes
one of my handlers, from each control that has more than one handler. Please
help!
How can I get this to stop??
Where are you putting the code to subscribe to the events?

If you are trying to put it all together in the section of code that
the Designer has marked off for itself... well, that bit says, "Don't
change this code!" for a good reason.

You can specify one handler for the event using the Designer, if you
like. The rest you must subscribe to somewhere else: many people do it
in the constructor, after the InitializeCompo nent() call. I like to do
it in the OnLoad() method for the form.

Either way, don't go hand-modifying the code that the Designer
generates, or, as you've seen, it will overwrite your changes next time
you change something on the form.

Aug 14 '06 #3
Also, it turns out that if the event handler that it removes from a control
isn't referenced elsewhere, it actually deletes my event handler method!
This is really bothersome.
--
Jaan
"jrett" wrote:
I'm working on a windows forms application and some of my controls have
multiple event handlers assigned to them. I haven't figured out how to add
multiple event handlers via the properties window, so I do it manually.
However, it seems that whenever I bring up a properties window, VS removes
one of my handlers, from each control that has more than one handler. Please
help!
How can I get this to stop??

--
Jaan
Aug 14 '06 #4
Thanks guys. That make so much sense now that someone has pointed it out to
me.

--
Jaan
"nick_nw" wrote:
>
jrett wrote:
I'm working on a windows forms application and some of my controls have
multiple event handlers assigned to them. I haven't figured out how to add
multiple event handlers via the properties window, so I do it manually.
However, it seems that whenever I bring up a properties window, VS removes
one of my handlers, from each control that has more than one handler. Please
help!
How can I get this to stop??

--
Jaan

Where abouts in your code are you writing the manual event handlers?

It should be done in the form's constructor, not in the windows
generated region.

Nick
http://seecharp.blogspot.com/

Aug 14 '06 #5

jrett wrote:
Also, it turns out that if the event handler that it removes from a control
isn't referenced elsewhere, it actually deletes my event handler method!
This is really bothersome.
Exactly how do you get that to occur? Which version of .NET are you
using? I'm using .NET 1.1 and I have never, ever had the Designer
delete an event handler method.

Aug 14 '06 #6

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

Similar topics

10
3607
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script language="JavaScript" type="text/javascript"> function show(that) { if (box.style.visibility=='hidden') { that.style.visibility = 'visible'}; }
13
3519
by: Charles Law | last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my question about removing event handlers. > http://www.vbinfozine.com/t_bindevt.shtml Following on from that post, the following issues still exist. The article shows how to find methods on a receiver that match the pattern OnXXXX given the sender. It loops through the sender events and tries to get methods from the receiver that match the pattern. For each one...
5
3887
by: Amit | last post by:
Hello! Is it possible to find how many event handlers an event has at runtime? How about finding whether or not an event has event handlers? In C# you can compare the event with null to check if it has event handlers, but I can't find the equivalent in VB. Thanks Amit
7
1718
by: Michael D. Ober | last post by:
Is there anyway to raise an event from a class and require that any program using that class (not just inheritance) have an event handler for specific events in the class? In my case, some events don't need to be handled, but some must be handled by the program that uses the class. I'm looking for something along the lines of Class MyClass Event OptionalEvent(parms) Event RequiredEvent(parms)
16
2519
by: Hamed | last post by:
Hello I am developing a utility to be reused in other programs. It I have an object of type Control (a TextBox, ComboBox, etc.) that other programmers use it in applications. they may set some of properties or assign event handlers. I need to be able to clone the manipulated control at runtime. I could use the Clone method of some objects (like Font, Style, String,
14
8644
by: Hamed | last post by:
Hello It seems that I should implement ICloneable to implement my own clone object. the critical point for me is to make a control object based on another control object that all of its event handlers are set like the old one. Is there a way to do this job? For example, is there a way to use EventInfo object to get all event handlers of the old control in runtime and set my new cloned control events to the event handlers of the old...
6
2124
by: Jake K | last post by:
Where is the best place to define event handlers? I need to define event handlers for a COM object referenced in my project and am doing so in the fowm load. Is this the best place?
5
3096
by: Lloyd Sheen | last post by:
Is there a way to get the event handlers such that I can cache the info about handlers for a particular control, remove the handlers, do some code and restore the cached event handlers in VB.NET (2008). I would rather do things this way than having to have a boolean flag to indicated to the handler to exit right away. Psuedo code: CacheHandlers(control)
6
2023
by: Tony Johansson | last post by:
Hello! I know it's possible to have several event handler for a single event but I can't see any point using several event handler for this. I'm probably wrong so can anybody tell me what advantage it might give using several event handler for a single event.
0
9688
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
10259
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...
1
10238
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9077
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...
0
6809
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4145
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 we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.