我正在制作一个基本表单 (WinForm) 以用作我的一般表单设计的蓝图,我希望面板(屏幕截图中的 P_Content)位于子表单中放置控件的位置。
但是说 P_Content 被锁定在子窗体中,在代码中添加控件显然可以,但在设计 View 中却不行。
面板是公共(public)的,其父容器 (TableLayoutPanel
) 也是公共(public)的。
这看起来很基本,但我似乎无法找到发生这种情况的任何答案。
P_Content 是大的空白空间。
最佳答案
您似乎在 TableLayoutPanel
中托管了 Panel
。根据documentations你应该避免 TableLayoutPanel
的视觉继承:
The
TableLayoutPanel
control does not support visual inheritance in the Windows Forms Designer. ATableLayoutPanel
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/