How to access inherited controls in the winforms designer

后端 未结 5 1288
盖世英雄少女心
盖世英雄少女心 2021-01-04 18:58

I\'m making some controls which all have to share the same look and some common behavior, although they are meant for different kind of inputs. So I made a BaseClass which i

相关标签:
5条回答
  • 2021-01-04 18:59

    Try making a ParentControlDesigner for your control, overriding InternalControlDesigner, and returning (designerHost.GetDesigner(tableLayoutPanel) as ControlDesigner). designerHost is (IDesignerHost) component.Site.GetService(typeof(IDesignerHost)).

    0 讨论(0)
  • 2021-01-04 19:03

    Try adding this attribute to the definition of the panel (this may or may not help):

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    
    0 讨论(0)
  • 2021-01-04 19:11

    I vaguely remember solving a similar problem by putting the base class it its own DLL and building it first. I've had a rummage but I can't find the project. Sorry.

    0 讨论(0)
  • 2021-01-04 19:16

    When you try to access from the inherited control with the designer to the TableLayoutPanel declared in the base control, you're using a feature in WinForms called "Visual Inheritance".

    Unfortunately TableLayoutPanel doesn't support visual inheritance: http://msdn.microsoft.com/en-us/library/ms171689%28VS.80%29.aspx

    That's why the TableLayoutPanel appears blocked in the inherited controls.

    0 讨论(0)
  • 2021-01-04 19:23

    You have to design the base controls on their own. Changes are reflected in the designer after you successfully rebuild the controls project. If you make the members public you can edit them but the changes won't persist.

    0 讨论(0)
提交回复
热议问题