How to easily duplicate a Windows Form in Visual Studio?

前端 未结 14 1432
梦谈多话
梦谈多话 2021-01-30 21:03

How can I easily duplicate a C#/VB Form in Visual Studio? If I copy & paste in the Solution Explorer, it uses the same class internally and gets messed up. How do you do it?

14条回答
  •  -上瘾入骨i
    2021-01-30 21:23

    I have been using another way of copying forms since vb6.

    1. File Menu / SE - Save CurrentForm.cs as - NewForm.cs
    2. Change its Name to NewForm in Properties window.
    3. In Solution Explorer - Add Existing Item - CurrentForm.cs
    4. Usually in MDI form (where CurrentForm is referred) - CurrentFormToolStripMenuItem_Click event - change reference back to CurrentForm (which is automatically changed to NewForm in step 1).

    comments welcome.

提交回复
热议问题