Overriding Container Controls - Design Time Problem

Hello,
I have created my own SplitContainer control by overriding the Windows.Forms.SplitContainer control.

In the constructor I call base() and then programmatically add a ToolStripContainer to SplitContainer.Panel1. This works fine, but I cannot click on the ToolStripContainer, or drag ToolStrips etc onto it at design tiime. When I drag a control from the toolbox onto the ToolStripContainer, the new control is added to SplitContainer.Panel1 and not SplitContainer.Panel1.ToolStripContainer (if you see what I mean).

I want to have the same design-time support for the ToolStripContainer as if I'd dragged it onto SplitContainer.Panel1 manually in the designer.

What can I do

Many thanks,
Ben


Answer this question

Overriding Container Controls - Design Time Problem

  • dev-one

    /me deleted his rubbish reply while working on a better solution Big Smile



  • Frohmen

    Okay, if I understand the problem you are experiencing, I think I may have found the answer.

    Try reading this and see if it works.
    http://blogs.msdn.com/subhagpo/archive/2005/03/21/399782.aspx

  • Lori D. Pearce

    Many thanks for the suggestion - much appreciated.
    Sadly I tried making everything public and it had no effect. My guess is that the secret lies in applying a designer attribute or something.
    Still looking...
    Thanks again,
    Ben

  • Half Abude

    WOW - that's it! Perfect answer - many thanks indeed.
  • Xavier Diab

    I had a similar issue with a panel I created in a user control that was being inherited by another user control. I couldn't add items to the panel at design time from the inherited control. What I ended up doing was changing the accessability of the panel directly in the base user control. Essentially, the designer needed access to the panel from the inherited control, but it was declared private when I originally added it to the base user control. Modifying it to protected (since it was being inherited) solved the issue. I know its probably not the cleanest solution and I couldn't get a property accessor to work instead of changing the direct object instantiation.

    So, try that out. Check if your ToolStripContainer is declared private or less than what the consuming Form can access and modify it to something the Form can access. That may work. It should be noted, the problem I mentioned seemed to only affect the designer. I could still programatically add controls to the inherited user control through normal, convential means, just not through the designer unless I changed the accessability for the control I wanted to mess with in the designer.

  • Overriding Container Controls - Design Time Problem