简体   繁体   中英

Creating solution from a single c# file, how to get the windows form designer to work?

I have got a single c# file, (a plugin for a CAD software) and have to extend it. Someone wrote the original in Visual Studio, and just copied everything into a single file. It contains everything, even the "required method for designer support".

My question is, how could I tell Visual Studio that this single file contains everything, and enable the form designer?

I tried to create a new solution from the file, added all the obscure dll references and what not, but have no idea how to go about the form designer. Also tried to add a new form, and overwrite it with code extracts from the aggregate source file, but I don't understand how it should work.

An easy way to deal with the situation is to create a Windows Form Project and add your source code file into this project. Then you can switch over to the designer and see the form in design view.

If you plan to make further changes to it, I would advise you to copy the mechanism Visual Studio uses: Separate the auto-generated code into a separate partial class called {classname}.designer.cs and keep the rest of the user specific code in the corresponding {classname}.cs file. I would just replace the code of an existing form with my code (both for user code and designer) to make sure everything works well with Visual Studio

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM