I'm using Visual Studio, I have generated a form & added a button but unfortunately I have named btn_test1 instead of Btn_test1 (small vs large beginning letter) & double clicked the button to generate the click function and visual Studio happily generated the: btn_test1_Click() function & then complained that the function didn't start with a capital letter.
I thought: "Ok, no problem", went back & renamed the button to Btn_test1 & changed the click function to Btn_test1_Click() and now instead Visual Studio gives me an error that btn_test1_Click() is missing.
My question is: What is the proper procedure I should have used in this case?
If you don't want to write a long answer but have a link to some documentation it's fine too.
Okay, there is no need for a capital letter at the beginning of a name property, I'm also using VS 2017. I'll give some screenshots how to rename a function.
Step 1: Click on the events of the button in the properties panel as shown in the following image
Step 2: Find click event, and Delete the text


Step 3: Go to Properties in the properties panel

Step 4: Select the Name property of the button.

Step 5: Rename it as you like,

Step 6: Double click the button on the designer, it will automatically create a function with the new name.
As for the naming convention, use as I mentioned in the image.
for example, a button to send something can be named as btnSend. btn -> stands for button. Send -> represents the name.
Note:
After you have successfully renamed and generated the new click event code. The old click event code will just be there. If you need the content of the old event copy it to the new click event code.
Also, if you still stuck with some error states that the old function is missing. Read the Designer.cs file carefully and delete all lines associated with the old function name.
Form1.cs [Design] crashes when you try to delete the event that is bound with button.
While making such changes -
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With