Visual Inheritance - Add controls at designer to a Panel hosted in TableLayoutPanel
Asked Answered
V

1

6

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.

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

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 being the big empty space.

Screenshot

Villeinage answered 18/4, 2018 at 7:55 Comment(2)
It seems you have hosted the Panel in a TableLayoutPanel. According to the documentations you should avoid visual inheritance for 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.Nope
@RezaAghaei That's it. This is why this didn't make any sense. Thanks a lot :DVilleinage
N
8

Its seems you have hosted the Panel in a TableLayoutPanel. According to the documentations you should avoid visual inheritance for 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.

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

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

Nope answered 18/4, 2018 at 8:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.