Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I use a button and write codes inside it's any event (e.g. "click" event like "private void button1_Click(object sender, EventArgs e)"). But few time later this button is not working because it's create dummy event and the name is "private void button1_Click_1(object sender, EventArgs e)". How to filter it?? please give the solution as soon as possible.
Posted
Comments
Praveen Kumar Upadhyay 24-Dec-14 7:16am    
Show your code please. What is the mean by few time later it is not working??
Sergey Alexandrovich Kryukov 24-Dec-14 10:34am    
Who told you "it creates dummy event"? What do you even mean by that?
—SA
Philippe Mori 24-Dec-14 16:36pm    
As mentinned in solution 1, events Handler are created mainly by double clicking on a control (or in the property grid).
Which version of Visual Studio are you using as recent version usually automatically remove empty event Handler when you delete it from the designer.

1 solution

What has happened is that you have created a method, and then added a Click event handler, probably by double clicking the button.
Do this:
Highlight the button in the Designer, and look at the Properties pane.
Select "Events" by clicking on the "lightening bolt" button.
Find the "Click" event in the in list, and look at the handler method to it';s right - this will be "button1_Click_1" - if it is, delete it, so the Click has no handler in the list.
Now go back to the code, and look for the "button1_Click_1" method - if it still exists, delete it.
Check your "button1_Click" method still exists.
If it does, go back to the designer, and look at the Click event in the properties pan again.
Use the drop down arrow to the right, and select "button1_Click" as the handler.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900