视觉继承-将设计器中的控件添加到TableLayoutPanel中托管的面板中 [英] Visual Inheritance - Add controls at designer to a Panel hosted in TableLayoutPanel

查看:142
本文介绍了视觉继承-将设计器中的控件添加到TableLayoutPanel中托管的面板中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个基本表单(WinForm)以用作一般表单设计的蓝图,我希望该面板(屏幕快照中的P_Content)可以放置在子表单中。

I'm making a base form (WinForm) to use like a blueprint for my general form design, I want the panel (P_Content in the screenshot) to be where controls are put in the Child Forms.

但是说P_Content被锁定在子窗体中,在代码中添加控件显然是可行的,但是在设计视图中却没有。

But said P_Content is locked in the child forms, adding controls in the code obviously works but it does not in Design View.

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

The panel is public and so is its parent containers (TableLayoutPanel).

这似乎很基本,但我可以似乎找不到答案,为什么会这样。

This seems really basic but I can't seem to find any answer why this is happening.

P_Content是很大的空白空间。

P_Content being the big empty space.

推荐答案

似乎您托管了 Panel TableLayoutPanel 中。根据文档,您应该避免对 TableLayoutPanel 进行可视继承:

Its seems you have hosted the Panel in a TableLayoutPanel. According to the documentations you should avoid visual inheritance for TableLayoutPanel:


TableLayoutPanel 控件在
Windows窗体设计器中不支持可视继承。派生的
类中的 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 ,它是记录,其中某些其他控件也不支持从基本表单的可视继承,并且将始终是只读的并显示为已锁定

The behavior is not limited to TableLayoutPanel and it's documented that some other controls also do not support visual inheritance from the base form and will be always read-only and appear as locked in the inherited form regardless of the modifiers you use:


并非所有控件都支持从基本表单的可视继承。以下控件中的
不支持此
演练中描述的方案:

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

  • 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).

这篇关于视觉继承-将设计器中的控件添加到TableLayoutPanel中托管的面板中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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