如何将Designer生成的类的基类从System.Windows.Forms.Form更改为我自己的BaseForm [英] How to Change Base class of Designer generated class from System.Windows.Forms.Form to my own BaseForm

查看:114
本文介绍了如何将Designer生成的类的基类从System.Windows.Forms.Form更改为我自己的BaseForm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我向WinForms项目中添加一个新Form时,设计器都会生成一个继承自System.Windows.Forms.Form的新类的代码.

Everytime I add a new Form to my WinForms project, the designer generates code of a new class which inherits from System.Windows.Forms.Form.

由于某种原因,我希望它从我自己的BaseForm类继承.除了自己编辑生成的文件之外,还有其他方法可以自动化吗?

For some reason, I want it to inherit from my own BaseForm class. Any way to automate it other than editing the generated file myself?

谢谢!

推荐答案

这实际上是Visual Studio直接支持的方案.从您的项目中添加一个新项目.在显示的对话框中,选择继承的表单".在下一个窗口中,您可以选择要用于新表单的基本表单.

This is actually a scenario that Visual Studio supports directly. From your project add a new item. From the dialog that is displayed select "Inherited Form." The next window should let you select the base form you want to use for your new form.

这篇关于如何将Designer生成的类的基类从System.Windows.Forms.Form更改为我自己的BaseForm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆