开发者

Visual Studio 2008: Adding components to inherited panel

开发者 https://www.devze.com 2023-01-13 18:55 出处:网络
In this scenario I have a base component with a close button and a flow panel; (FlowLayoutPanel) the idea being that components extending this add their controls to the flow panel and will have the cl

In this scenario I have a base component with a close button and a flow panel; (FlowLayoutPanel) the idea being that components extending this add their controls to the flow panel and will have the close button functionality done for them.

The problem is that I can't seem to persuade VS to add the components in the subclassed component to the flow panel; this ends up with me having to do so in the code. Which is all well and good except that it won't show up in the designer view. If I add it to the partial class with the designer generated code then I can see the controls in the d开发者_如何学Pythonesigner view laid out by the flow panel. But this just gets overwritten afterwards.

Visual Studio doesn't seem to let you dock controls in inherited panels - unless I'm doing something wrong? I did make sure that the base panel is publically visible in case this was the issue.

--

An alternative might be some way to persuade the designer to execute/not overwrite my code in the designer class.


You need to make a ControlDesigner for your control and override the InternalControlDesigner and GetParentForComponent methods.

For an example, open System.Windows.Forms.Design.SplitContainerDesigner (in System.Design.dll in Reflector.

0

精彩评论

暂无评论...
验证码 换一张
取 消