0

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.

1
  • It just did not occur to me to try it the other way around. But now I tried it, and embarrassingly it simply works, thanks. Commented Aug 11, 2017 at 19:31

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.