Solved

Event Names Keep Changing

Posted on 2008-10-06
7
211 Views
Last Modified: 2013-12-17
Sometimes randomly buttons will stop working, and it turns out that its because the event method name has changed.  For example:
private void button1_Click(object sender, EventArgs e)
to
private void button1_Click_1(object sender, EventArgs e)

Is there anyway to stop this from happening?  OR to easily change the code when it does?  As currently I have to cut all code from the original button click event to the new one.
0
Comment
Question by:angus_young_acdc
  • 3
  • 2
  • 2
7 Comments
 
LVL 13

Accepted Solution

by:
SameerJagdale earned 500 total points
ID: 22648829
in design view, you get the events information in properties grid (watch the lightning bolt) select the appropriate event (in your case it is click), then from drop down select the event you wish to subscribe.
Does it make sense?
0
 
LVL 15

Author Comment

by:angus_young_acdc
ID: 22649870
Hi yes I understand, its just rather annoying to have to do that for each individual control.  So I was hoping for a simpler solution if there  was one.
0
 
LVL 13

Expert Comment

by:SameerJagdale
ID: 22649906
you can do the changes in initializecomponent directly.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 22650428
"Sometimes randomly buttons will stop working, and it turns out that its because the event method name has changed"

This isn't a "random" event...this happens when you CUT and PASTE a control from one place to another.  When you Cut the control the handler is automatically removed.  Then when you Paste it again and and rewire it...the IDE sees that there is already an existing method with the name it wants (from the previous stub handler) and so it creates a new method stub by adding the number after it.

0
 
LVL 15

Author Comment

by:angus_young_acdc
ID: 22650580
I know that it happens when you cut/paste controls, however I have not been doing that which is why I see it as randomly changing.  They are not even being moved anywhere (and there is no panel to be their parent).
0
 
LVL 15

Author Comment

by:angus_young_acdc
ID: 22691248
Can anybody help solve this?
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 22691342
We already listed the common cause of this and you said that wasn't it...not sure what else to suggest!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now