Hi,

How to add an existing form of old project to a new project? Which extension type files to be added to work that existing form correctly?

I actually need (because a lot of textboxes and other controls are there) which I have added now to my New Project. Since it doesn't show any existing controls on form, I added other following files as well. Though there is no use. Please help.

1)
2)
3)

Thanks.

Dani AI

Generated

Good point from — Visual Studio will usually pull designer and resource files when you add a form file — but if the form opens blank after adding it (the situation reported), a few common issues explain why and how to fix them.

  • Confirm all three pieces exist and are included in the project: the form code-behind, the .Designer.vb (contains InitializeComponent and control declarations) and the .resx (resources). If the Designer or .resx aren’t nested under the main form file in Solution Explorer, add them manually or use "Show All Files" then "Include In Project".
  • Verify the class declaration and pairing between files. The code-behind and Designer must declare the same partial class and inherit Form. For example:
    Partial Public Class frmContacts
      Inherits System.Windows.Forms.Form
    End Class
  • Make sure the namespace/root namespace matches across files; a mismatch prevents the designer from associating the parts. Also check that the designer file actually contains Sub InitializeComponent() and the Friend WithEvents control declarations.
  • Designer load fails if there are compile-time errors or runtime-only code executing during construction. Build the project, open the Error List, and remove or guard runtime code (move it to Load or wrap with a design-time check). In Load handlers use:
    If Not Me.DesignMode Then
      ' runtime-only initialization
    End If
  • If nesting is wrong, edit the .vbproj to set DependentUpon so Designer and .resx attach to the form:
    <Compile Include="frmContacts.Designer.vb">
    <DependentUpon>frmContacts.vb</DependentUpon>
    </Compile>
    <EmbeddedResource Include="frmContacts.resx">
    <DependentUpon>frmContacts.vb</DependentUpon>
    </EmbeddedResource>

Quick remedies: Clean/Rebuild, restart Visual Studio, unload/reload the project, or remove and re-add the files. If the designer still fails, create a new form and copy the designer code and resource entries across after ensuring names and namespaces match.

Recommended Answers

All 2 Replies

From the solution explorer, choose Add + Existing item + (Rest files will be copied automatically)

From the solution explorer, choose Add + Existing item + (Rest files will be copied automatically)

Thank you very much for the help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.