Visual Studio C#: How to duplicate a form without messing up?

VAer-4038 771 Reputation points
2020-12-31T16:18:29.783+00:00

Right Click: FormChild.cs, then paste. But I guess it will mess up something.

How should I duplicate a form? I would like to duplicate a form then make a little adjustment, rather than creating a new form.

Thanks.

Developer technologies Windows Forms
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Daniel Zhang-MSFT 9,651 Reputation points
    2021-01-01T02:45:38.693+00:00

    Hi VAer-4038,
    Visual Studio include a template form feature.
    So you can follow the steps to achieve it.

    1. Select Export Template... from the Project menu.
    2. Select Item template (you only want the form "item").
    3. Ensure that the project containing the form is selected in the combo box. Then click Next.
    4. Check the form that you want (FormChild.cs) in the "Select Item to Export" list. Then click Next.
    5. Optionally include references you want with the item. Then click Next.
    6. Give this "template" a name you will recognize like "FormToCopy". Then click Finish.
      Now, the form is a "template".
      Next, you can add this "FormToCopy" form to you project.
      Please follow this:
      Right click your project name-> Add-> New Item..., you will find the "FormToCopy" and add it.
      52684-111.png
      Hope this helps.
      Meanwhile, there are more methods in this thread you can refer to.
      Best Regards,
      Daniel Zhang

    If the response 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.

    3 people found this answer helpful.
    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.