When I made a custom control today, I encountered a problem usingCodeWhen writing code to a file, there is no corresponding thing in the designer, but the following error message appears: Class XX can be designed, but it is not the first class in the file.
Visual Studio requires the designer to use the first class in the file. Move the class code to make it the first class in the file, and then try to reload the designer.
At this time, the CS file icon in the vs resource manager will become installed.ProgramClass icon. However, you can right-click the menu and use "view code" to open it with vs. You can use Solution Explorer to browse the icon or "code file. CS icon, double-click in Solution Explorer. the CS file vs is opened normally. The above prompt is displayed. The specific reason is that for controls with a designer, the class where the control is located is the first. Finally, you only need to cut the XX class shown above to the top of the class in the code, save it once, and generate it again. The problem is solved.