I have a project that has only one form, that is Form1.vb.
When I double click this file to edit the controls with the toolbox, the file is opened, but it is empty.
The strange thing is that when I compile and run the project, the GUI that I had created in this file (Form1.vb) is shown like it whas there, but as I said, the file is empty, so I can't edit the GUI.
How can I fix it?
This is what I would do first: Click on "My Project" in Solution Explorer and check out under Application what your Startup form and Application type is.
Solved.
I can't get the code of Form1.vb, but I created a new form and copy the code of Form1.Designer.vb (this file was in my folder, and due to it the GUI was shown when I compile & run the project) to the form designer file of the new form. To did it, I opened the file with a text editor.
It allowed me to edit the existing GUI preserving the properties of the controlls that I had created.
Your code file might be empty but the
.Designer.vb
file is not (from the screenshot it's seen that it's 15 KB).The problem here is that your project seem to have lost the "link" between the designer file and the code file, and treats
Form1
as a normal class.If you don't have a backup of your code file you will not be able to get your code back, but you can still make your form editable again by following these steps:
(This step is very important) Go into your project folder and copy
Form1.vb
,Form1.Designer.vb
andForm1.resx
to another folder.Now that you have a copy of the files, go a head and delete Form1 from Visual Studio, and delete any left-over Form1 files from your project directory.
In Visual Studio right-click your project and go to
Add > Existing file...
. Browse to the folder where you copied the Form1 files in step 1, and select all three.Press "Open", and the form should now be imported to your project as an editable form again.
EDIT:
Try opening the
Form1.vb
in Notepad and write:in it, then redo the steps above.