I imagine this question has been asked and answered, but I cannot find it.
I wanted to make a simple GUI to interface to a windows 7 command. I usually use Wx, but since this was to be a windows-only thing, I decided to see if I could whip it out real fast using Visual C# 2010 Express, which I had never used before.
Things started off just great. I created a form, put a few buttons and text boxes and such on it, and hit Debug. It came up and ran just like that. No muss, no fuss. So I then designed the form just the way I wanted it, renamed the controls from “Button1” and so forth to meaningful names. But now it’s a mess. By clicking around, I discovered that VC# had auto-generated two files called Form1.cs and Form1.Designer.cs. The later contains the bindings between functions and the events generated from user-clicks etc., and the former contains no-op code for those functions, for me to complete.
Problem is, the names are all still the original “Button1” and so forth, not the new ones, and the new controls I added after running the first time do not appear at all.
I want it to regenerate all that stuff afresh from the finished form. How to?
You probably don’t have an actual problem, unless you edited something within
Form1.Designer.cs. Provided you left that file alone, things should just work.Whenever you double-click on a button, or use the events interface to create event handlers, the handlers are created with the following pattern:
So, for example:
If you later change the name of Button1, the event handler’s name is not changed, too. But it is still attached to the proper event, again – assuming you did not edit anything in Form1.Designer.cs
If you look (but don’t touch!) inside Form1.Designer.cs, you will probably find something similar to:
(I don’t recall the exact syntax the editor uses for wiring up event handlers; the principle is you should see your new button name being attached to the old handler name)