Results 1 to 5 of 5

Thread: how to clean form.designer.vb?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    362

    how to clean form.designer.vb?

    I copy/paste controls in the projects, then I noticed that there are many controls are listed in designer.vb which actually are not being used. how can I clean these? will it affect the UI performance? or, it does nto matter at all?


    thanks

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: how to clean form.designer.vb?

    If for some reason the designer.vb files lists controls that are no longer used or needed, then you can just delete all references to them in the designer file and rebuild your project. The file is nothing more than auto generated code that one could write themselves. It is not different in any way (with the exception that at any point the IDE could regenerate the file, so putting custom code in there is never a good idea)

  3. #3
    PowerPoster cicatrix's Avatar
    Join Date
    Dec 2009
    Location
    Moscow, Russia
    Posts
    3,654

    Re: how to clean form.designer.vb?

    designer.vb is autogenerated so I doubt there are some controls that are not used. Well, sometimes it gets messy.
    Try clicking View/Other Windows/Document Outline
    Default hotkey: CTRL+ALT+T

    All controls will be displayed in hierarchical order. You can check whether there are unnecessary ones and delete them (or click and drag them along the tree).

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2004
    Posts
    362

    Re: how to clean form.designer.vb?

    thank you both.

    yes, designer.vb is auto generated, however, when I copy/paste controls, especially tab, and then rename the controls later, it leaves many unused controls in the designer.vb. I did not notice this until I used the same form for different projects (which means I copied/pasted many times). so, lots of unused controls, it makes really difficult to remove the controls manually from the file. is there a feature that I can force VS rebuild it?


    thanks again.

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: how to clean form.designer.vb?

    The only thing I can think of is if you did something like this:

    1) highlight ALL the controls on the form (I assume whatever controls are actually visible on the form in the designer are controls you want to keep)
    2) ctrl+c to cut all the controls off the form so it is now a blank form
    3) go into the designer file, and all the code from the controls you wanted to keep will be gone, so now you can delete all the extra crap that is in there with regards to phantom controls.
    4) go back to the blank form designer, and ctrl+v to paste the controls back to the form, which in turn will put their code back into the designer.vb file

    The only downside to this approach is that it will remove any auto wired up event handlers in your code (any control that has an event handled with the Handles clause on a subroutine). You won't lose the code, just the handles clause on the end of the sub. You would have to add those back manually.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width