views:

21

answers:

1

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 designer 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.

+1  A: 

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.

SLaks
Hmm, don't seem to be getting anywhere. Tried the example here http://msdn.microsoft.com/en-us/library/system.windows.forms.design.controldesigner%28v=VS.90%29.aspx Only seems to work when done within another form or component; it doesn't seem to activate when designing the component itself.
cyborg
That might not be possible.
SLaks
It does knida look that way - if I don't get any better answers I'll accept yours.
cyborg