Clean up Designer.vb file in Visual Studio 2008 - vb.net

I noticed that my Designer.vb file of one of my forms has a lot of controls that aren't even used or visible on my form. This is probably from copying controls from my other forms. Is there a way to clean up the Designer.vb file and get rid of all the unused controls?
**UPDATE: This is for a Windows Form project.

The only real solution I see is to copy all the controls into a new form by selecting them in the designer. This way all the not created controls should not follow you to the next form.

Related

How can I recreate a designer.vb file?

I have a windows forms application in which one of the designer.vb files is missing and has apparently been missing for years (checked all my backups). When I right-click on the vb file in Solution Explorer and select "View Designer", nothing happens. The Windows form designer generated code is still in the vb file, and the form shows up fine when the application runs. Is there any way to recreate the designer file so I can edit the form?
Create a new Form and copy the code from the InitializeComponent method of the old form into the same method in the ".designer.vb" file of the new Form (and replace the existing code in this method.). Also copy the designer generated variable declarations.
Since InitializeComponent creates all the controls and sets all the form properties, this copies the whole design of the old form to the new form.
You will have to copy your own code (containing Load and Click methods and so on) from the old ".vb" file into the new ".vb" file as well.

Display controls in Designer VB.Net 2013

I have a set of controls which are added dynamically to a panel. The number of controls depends on which tab a user selects from TabPage control, which is embedded in a form.
At the moment, the controls don't appear in Designer, but appear during execution.
I managed to display controls for other forms which are not dynamic by moving the non-design code to the vb file, but how can I display the other ones?
The only answer that I know of is to add your code in the .Designer.vb file of the Form.
BUT! I strongly advise you to avoid that if you are not sure how it works! Custom code in the .Designer. files can break your form design and project with possible random crashes.
Also, your code can be changed and removed by the Visual Studio designer:
Custom code in designer.vb file goes away when making edits in design mode
Instead, you can make the panels into custom user controls and add those to the tabs.

How to find a form from many forms in vb6 on a existing project

I am working on a old project of vb6 which has hundreds if forms. I am able to run the application and have to fix a runtime error in a form which pop up. I don't know the name of the form and only have visual reference. I tried using debug but It has continues SQL statements running in a loop. Any advice is appreciated.
Thanks.
Search the code for the form caption, or the labels of controls on the form, using visual studio's "find in files" or simlar function of your favourite editor.
If the caption is set in the form design, this will take you to the .frm file the form is stored in. You can open this in Notepad or another editor to get the name of the class (which is usually the same as the filename).
If the caption is set in code, you can place a breakpoint on that line. Again, this will lead you to the code which instantiates the form.

Replacing several winforms controls with custom controls in VS2010

I have inherited a VB.net project, and I need to give several ListBoxes some custom functionality. So I've created a subclass of System.Windows.Forms.ListBox, and now I'd like to replace several "regular" ListBoxes with my subclass.
I want to be extremely careful not to change any properties that are set in the designer, so I'm hoping to just "drop in" my replacement.
Does the VS2010 winforms designer have a built-in way of simply changing the user control's type, without deleting and re-inserting the control?
You will need to change the type in the Form.designer.vb file. Every control used on the form is declared in there.
In my experience it will be best to use the Visual Studio find and replace tool to replace the ListBox control where you need to in all the .ASPX files as well as the .designer.cs files.
You'll need to add a reference to your control's assembly in the .ASPX files too.

Corrupt forms, not displaying in "startup form"?

In properites>Application>"Startup form" combobox, in my VS VB.NET project, I see only 2 forms listed, while my application has 6 forms. Does this mean something is corrupt?
I tried to make a new project, then copy only the old vb files into this new project. But still only those two (of 6) forms show up in the "Startup form" combo box.
Well, that's pretty odd. This list is almost certainly filled from the project file, the <SubType> element should be significant. But you eliminated that possibility by recreating the project file from scratch. I can't see how a property on a form would make it disappear from the list.
One thing you could try is editing the My Project\Application.myapp file with Notepad. Copy the solution first and make sure it isn't loaded in VS. Change the <MainForm> element to one of the forms that isn't listed. Load the project and see what is shown in the project property page and if anything breaks when you compile it.