Rebuild Windows Forms Designer Generated Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to rebuild the code that is generated by the forms designer? It compiles, but it seems to have controls left in it that I previously removed using the designer. I'd like to just rebuild it all to ensure it is clean and does not have unnecessary code in it. (The Rebuild command does not do this.)
 
gsilvey,
The "Oh my god, what have I done method":
- Open your form in the Forms Designer
- Use Edit Select All to select all the controls
- Use Edit Delete to delete all the controls
- Use the toolbox to add all the controls you actually want
- Use the properties window to set the properties you actually want

Otherwise, there is no way to "rebuild" the code, as the code generated IS
your form design (the design is not stored any place else). There is
additional information on the design in the .resx file, however the bulk of
the form's design is the generated code itself.

Hope this helps
Jay

gsilvey said:
Is there a way to rebuild the code that is generated by the forms
designer? It compiles, but it seems to have controls left in it that I
previously removed using the designer. I'd like to just rebuild it all to
ensure it is clean and does not have unnecessary code in it. (The Rebuild
command does not do this.)
 
Hi Jay,

I was just thinking about you and thought, Jay never makes jokes in this
newsgroup always serious and than this.
The "Oh my god, what have I done method":

I was really laughing (friendly of course).

Cor
 
Cor,
I wanted to make sure that gsilvey was thinking before he actually tried my
method...

Jay
 
I've got way too many controls to do that. Your suggestion gave me an idea though. I did a select all and then a delete. I then went to the source viewer and removed what was left. There were still about 20 controls in there. I then went back to the designer and did a paste. That seems to have worked, however I still get the error I was previously getting... (See my other thread here about InitializeComponent() exception in .NET General
 
Back
Top