简体   繁体   English

VB2010或VB.NET更改默认表单属性

[英]VB2010 or VB.NET changing default form properties

Is there any way to change the default form properties when starting a new forms project, or adding a new form to an existing project. 启动新表单项目或向现有项目添加新表单时,是否有任何方法可以更改默认表单属性。 For example... the current default for any new form created for "Start Position" is "Windows Default Location"... but I want every form to be "Center Screen".... also, the default "AutoScaleMode" setting is "Font".... I want this to be "None"... yes, I can change these settings in the properties when I create the new form, but I want to change the default. 例如...为“开始位置”创建的任何新表单的当前默认值为“ Windows默认位置” ...但我希望每个表单均为“中心屏幕”...。还有默认的“ AutoScaleMode”设置是“字体”。...我希望将其设置为“无”。是的,我可以在创建新表单时在属性中更改这些设置,但我想更改默认设置。 It is annoying having to change these (and a few other) setting every time I create a new form. 每次创建新表单时都必须更改这些(以及其他一些)设置,这很烦人。

You could edit the default Item or Project templates stored in C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\ . 您可以编辑存储在C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\的默认ItemProject模板。

I would suggest that you create your base Form/Project and export them; 我建议您创建基本的Form / Project并将其导出; File Menu->Export Template. 文件菜单->导出模板。 You often need to do a bit of touch up of the wizard generated files with a text editor though. 但是,您通常需要使用文本编辑器对向导生成的文件进行一些修饰。

To learn more, see: Visual Studio Templates 要了解更多信息,请参见: Visual Studio模板


Edit: The template wizard will drop the custom project template in the C:\\Users\\USERNAME\\Documents\\Visual Studio 2010\\Templates\\ProjectTemplates folder when you have left the "Automatically import the template into Visual Studio" option checked. 编辑:选中“自动将模板导入Visual Studio”选项后,模板向导会将自定义项目模板拖放到C:\\Users\\USERNAME\\Documents\\Visual Studio 2010\\Templates\\ProjectTemplates文件夹中。 There should be a sub-folder named "Visual Basic" in that folder. 该文件夹中应该有一个名为“ Visual Basic”的子文件夹。 Any folder you add under "Visual Basic" will show up under the "Installed Templates" view. 您在“ Visual Basic”下添加的任何文件夹都将显示在“已安装模板”视图下。 You can move your template file (the zip file) to a specific folder in that folder hierarchy to categorize your templates. 您可以将模板文件(zip文件)移动到该文件夹​​层次结构中的特定文件夹,以对模板进行分类。 I hope that that description made sense. 我希望这种描述是合理的。

Also, if you choose to modify the system template structure located under C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\ , you will need to update the cache by executing the following command in a Command Prompt window. 另外,如果您选择修改位于C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\下的系统模板结构,则需要通过在命令提示符窗口中执行以下命令来更新缓存。

devenv /installvstemplates

Easy solution: Create a form you want as your default with all the parameters setup. 简便的解决方案:使用所有参数设置创建您想要的默认表单。 Then just copy the designer view and the code view into their respective places for the new form. 然后,只需将设计器视图和代码视图复制到新表单的相应位置即可。 You can do this between projects 您可以在项目之间进行此操作

If it is within the same project you can just copy past the form in the solution explorer to generate more based off the template you created. 如果它在同一个项目中,则只需在解决方案资源管理器中复制表格即可,然后根据您创建的模板生成更多内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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