How do I copy a form and rename it in VS2015

Lenny Gray
Lenny Gray used Ask the Experts™
on
I have a complicated form with a lot of controls on it. I would like to copy that form and rename it so that I can re-code the code behind the form. I am learning VB.NET and I would like to preserve a working copy of the form while I experiment with the same form using different code approaches.

I am not looking to create a new class just for this form. I am do this simply as a learning process for variations of coding within a form.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014
Commented:
I do it like this:

1. Highlight the form in the Solution Explorer and click Ctl-C and Ctl-V. This will make a copy of the form named <formname>-COPY
2. In Windows Explorer, I then open the ".designer.vb" file with a standard text editor (like Notepad) and change the name of the Class
3. Again in Windows Explorer, I open the ".vb" file and change the name of the Class.

The name of the Class in 2 and 3 must match, of course.

When you return to VS, you'll be notified that the files have been changed externally, and asks if you'd like to reload them. Accept that, and you should be good to go.

Here's a picture that shows the file loaded in an editor, with a box around the name. The name of the "original" class in this case was "rTeamScores". I changed it to "rTeamScores2":
Class Name
And in the Designer file:
ClassName Change Designer file

Author

Commented:
Thanks for your quick response!  When I had done the copy on my own, I never knew that I had to do items #2 and #3, as you had pointed out.

I appreciate your help!!!

Thanks!!

Lenny

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial