英文:
Can a Form inherit controls from parent form in VB.NET?
问题
我是Visual Studio的初学者,正在使用VB.NET开发WinForm应用程序。我希望子窗体可以继承菜单栏或工具栏等控件,而不需要在每个窗体中都重复创建相同的控件。
在旧版的VBA中,我可以使用多页面来实现这一点,只需更改窗体的底部部分而不影响其余部分,但在Visual Studio中是否也可以实现这一点?正如我之前提到的,我是初学者,希望得到详细的回答。
英文:
I'm a beginner in Visual Studio and i'm developing a WinForm using VB.NET.
I would like to have child forms to inherit controls as menu strips or tool strips without creating the same ones over and over as i pass to other forms.
In old VBA i could do that with multipage, just changing the bottom part of the form without touching the rest, but is that possible in Visual Studio?
As previously said i'm a beginner so i hope in detailed answers.
答案1
得分: 3
- 添加一个新表单。
- 单击 解决方案资源管理器 中的 显示所有文件 按钮。
- 展开表单节点。
- 打开设计师代码文件。
- 编辑
Inherits
行以继承您所期望的基础表单,而不是标准的Form
类。
就是这些。继承的工作方式一直都是一样的。
英文:
- Add a new form.
- Click the Show All Files button in the Solution Explorer.
- Expand the node for the form.
- Open the designer code file.
- Edit the
Inherits
line to inherit your desired base form instead of the standardForm
class.
That's all there is to it. Inheritance works the same way all the time.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论