可以为在 Visual Studio 中创建的新 WinForms 设置默认属性吗? [英] Can one set the default properties for new WinForms created in Visual Studio?
问题描述
每当我创建一个新的 WinForm 时,FormBorderStyle 默认为 Sizable.如果我可以配置 VS 以便我创建的每个新表单都具有 FormBorderStyle=FixedDialog(并且与其他几个属性类似),那将会非常方便.
Whenever I create a new WinForm, the FormBorderStyle defaults to Sizable. It'd be really convenient if I could config VS so that every new form I create has FormBorderStyle=FixedDialog (and similar with several other properties).
有谁知道VS是否允许您更改默认属性?
Does anyone know if VS allows you to alter the default properties?
推荐答案
我认为您必须创建自己的表单模板
,这里有一些步骤:
I think you have to create your own Form template
, here are some steps to do it:
步骤 1: 在当前项目中创建您自己的表单类,只需将默认表单添加到项目中,然后将 FormBorderStyle
设置为 FixedDialog
属性窗口
中的代码>.在此示例中,我将表单类命名为 FixedDialogForm.
Step 1: Create your own form class in the current project by simply adding the default form to the project, then set the FormBorderStyle
to FixedDialog
in the Properties window
. In this example, I named the form class FixedDialogForm.
第 2 步: 打开 Export Template
向导窗口:
第 3 步: 按照说明完成向导,我们必须选择类文件、要包含在模板中的引用、模板图标:
Step 3: Follow the instruction the complete the wizard, we have to choose the class file, the references to be included with the template, the icon of the template:
毕竟,您可以正常添加自己模板的新表单,但要注意模板表单位于我的模板组下:
After all, you can add new form of your own template normally but with a notice that the template forms are under the group My Templates:
这篇关于可以为在 Visual Studio 中创建的新 WinForms 设置默认属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!