How to easily duplicate a Windows Form in Visual Studio?

前端 未结 14 1549
梦谈多话
梦谈多话 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
    慢半拍i (楼主)
    2021-01-30 21:27

    1. Copy and paste the form.
    2. Rename the pasted form .cs to match the new form class name. This should auto rename other related files.
    3. Open up .cs file. Change the class name and the name of the constructor(s) and destructor.
    4. Open up .Designer.cs file and change the class name.

    Extra Credit:

    1. Consider abstracting common functionality from the form into common form or controls.

提交回复
热议问题