Role of Designer.cs File in c#

前端 未结 2 652
天涯浪人
天涯浪人 2020-12-16 02:37

I am getting Designer.cs file in my project and the comment in the file says it is being generated by an automatic tool.

This was an existing project so I don\'t k

相关标签:
2条回答
  • 2020-12-16 03:24

    Designer.cs contains the declaration and initialization of UI controls and layout of form. The form is rendered based on the information provided in designer.cs. This file is autogenerate when a form is created in design mode.

    0 讨论(0)
  • 2020-12-16 03:29

    There are lots of kinds of Designer.cs files in a Visual Studio project. Common ones are:

    • Properties\Resources.resx\Resources.Designer.cs file, the auto-generated code from adding resources to the Project + Resources tab
    • Properties\Settings.settings\Settings.Designer.cs file, the auto-generated code from adding settings to the Project + Settings tab
    • SomeForm.cs\SomeForm.Designer.cs, the auto-generated code produced by the Winforms designer from the controls you drop on a form
    • SomeData.xsd\SomeData.Designer.cs, the auto-generated code produced by the dataset designer.

    Given that you name a database in your question it is somewhat likely that you are talking about the last one. You ought to see the pattern from the descriptions, you use a visual designer gadget in Visual Studio and it produces C# code that does something useful at runtime. You go back from the Designer.cs to the designer gadget by double-clicking its parent node in the Solution Explorer window. Don't ever edit the Designer.cs file, you'll lose everything when the designer re-generates the code. They are somewhat hidden in the Solution Explorer for that reason. If you haven't found them yet: open the nodes to see them.

    0 讨论(0)
提交回复
热议问题