VB.NET中的一个窗体是否可以从父窗体继承控件?

huangapple go评论50阅读模式
英文:

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

  1. 添加一个新表单。
  2. 单击 解决方案资源管理器 中的 显示所有文件 按钮。
  3. 展开表单节点。
  4. 打开设计师代码文件。
  5. 编辑 Inherits 行以继承您所期望的基础表单,而不是标准的 Form 类。

就是这些。继承的工作方式一直都是一样的。

英文:
  1. Add a new form.
  2. Click the Show All Files button in the Solution Explorer.
  3. Expand the node for the form.
  4. Open the designer code file.
  5. Edit the Inherits line to inherit your desired base form instead of the standard Form class.

That's all there is to it. Inheritance works the same way all the time.

huangapple
  • 本文由 发表于 2023年5月17日 16:41:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/76270115.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定