Visual Basic form, cannot open in Form Design view

Havooma 156 Reputation points
2022-04-07T16:28:47.53+00:00

So I made a mistake on one of my VB forms and deleted something I shouldnt have. No bother because I backed up the last version of the program I made a month ago.

Planned to delete the form in the Solution Explorer then go to Add -> Existing and select the form from the previous version.

I note that the form I am after has 3 files associated, a .vb, .resx and .Designer.vb. When I added this form, I used the .vb file.

It appears then in the solution explorer and works when I then run the software. However, Ive tried everything but cand open this form in the Form designer, when I double click on it, I just get the code view.

All 3 files have been imprted into the Solution Explorer, the .Designer.vb and .resx sit below the .vb file in the tree.

What I did notice is that the icon for this form is now 'VB' rather than a form icon. There is also no option to 'View Designer' when clicking on it.

Im sure Ive tried every single combination of everything! Is there something special I need to do when I add an existing, to ensure it is recognised as a form, not a 'VB'?

Developer technologies Windows Forms
Developer technologies VB
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 60,161 Reputation points
    2022-04-07T18:26:45.69+00:00

    Edit the project file in a text editor. Find the Form.cs file that you added back. Add a subtype of Form.

    <Compile Include="MyForm.vb">
       <SubType>Form</SubType>
    </Compile>
    <Compile Include="MyForm.designer.vb">
       <DependentUpon>MyForm.vb</DependentUpon>
       <SubType>Form</SubType>
    </Compile>
    

    Save and reload the project.

    0 comments No comments

  2. Jiachen Li-MSFT 34,221 Reputation points Microsoft External Staff
    2022-04-08T08:00:49.417+00:00

    Hi @Havooma ,

    1. Open the previous project directory and copy the three files of the form to the new project directory.
    2. Then go to Add -> Existing and select Copied Form.

    Hope this could be helpful.
    Best Regards.
    Jiachen Li

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.