c# - 视觉继承 - 将设计器中的控件添加到 TableLayoutPanel 中托管的面板

标签 c# .net winforms inheritance windows-forms-designer

我正在制作一个基本表单 (WinForm) 以用作我的一般表单设计的蓝图,我希望面板(屏幕截图中的 P_Content)位于子表单中放置控件的位置。

但是说 P_Content 被锁定在子窗体中,在代码中添加控件显然可以,但在设计 View 中却不行。

面板是公共(public)的,其父容器 (TableLayoutPanel) 也是公共(public)的。

这看起来很基本,但我似乎无法找到发生这种情况的任何答案。

P_Content 是大的空白空间。

Screenshot

最佳答案

您似乎在 TableLayoutPanel 中托管了 Panel。根据documentations你应该避免 TableLayoutPanel 的视觉继承:

The TableLayoutPanel control does not support visual inheritance in the Windows Forms Designer. A TableLayoutPanel control in a derived class appears as "locked" at design time.

该行为不限于 TableLayoutPanel,它是 documented一些其他控件也不支持从基本窗体的视觉继承,并且无论您使用什么修饰符,都将始终是只读的并且在继承的窗体中显示为锁定:

Not all controls support visual inheritance from a base form. The following controls do not support the scenario described in this walkthrough:

  • WebBrowser
  • ToolStrip
  • ToolStripPanel
  • TableLayoutPanel
  • FlowLayoutPanel
  • DataGridView

These controls in the inherited form are always read-only regardless of the modifiers you use (private, protected, or public).

关于c# - 视觉继承 - 将设计器中的控件添加到 TableLayoutPanel 中托管的面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51728675/

相关文章:

.net - .NET 中的双向数据绑定(bind)不起作用,即使使用 INotifyPropertyChanged 对象也是如此

c# - 如何设置VS 2010的reportviewer工具栏语言?

c# - 唯一的持久性控件标识符

c# - 如何使用等待语法从 Windows.Devices.Enumeration.DeviceInformation.FindAllAsync 读取结果?

c# - automapper 多对多关系映射

c# - 如何通过自定义Attribute获取和修改属性值?

c# - 原始文件比 GZip 解压文件大

.net - PreRequestHandlerExecute 中的 session 为空

c# - 按下退出键时如何关闭表单?

javascript - 使用 Jquery 在 asp.net GridView 中查找所有复选框