vb.netwinformsdesignersln-file

Trying to copy a form I created to a new project so I can reference it from multiple projects. Event 'Click' cannot be found


I previously created a windows form in a vb.net project but now I realized I can use this form in various other projects. Instead of copying the code to every project I want to use it in, I'm trying to create a new project, copy the code to this new project, and reference the new project anytime I want to use the form.

I created the new blank windows form project, copied the vb, resx, and designer files over to it. Then I opened the new solutions folder and selected "Add existing item" and selected the pre-existing vb file. I added references to System.Windows.Forms and System.Drawing to remove "Type 'Button' is not defined" errors but I'm still getting errors that "Event 'Click' cannot be found". Also, when I try opening the designer file I get this error: designer error

I've tried following previous answers concerning how to copy forms to new projects but still haven't been able to figure it out. I don't have much experience working with multiple projects and solutions so I'm probably making a simple mistake but I can't seem to find any other answers directly related to this.


Solution

  • You should not be copying anything. What you should have done is right-clicked the new project and selected Add - Existing Item, then selected the VB file for the form. That would have added the form to the project with all the required parts.