Solved

Event Names Keep Changing

Posted on 2008-10-06
7
217 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

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 86

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

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

Suggested Solutions

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 article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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…

740 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