Creating a custom container control

  • Thread starter Thread starter bram
  • Start date Start date
B

bram

Hello,

I'd like to create a custom control that exposes several containers,
much like the SplitContainer in VS 2005. However, when I create a
custom control with several panels and I drag a control onto the custom
control, it will become part of that custom control and not part of the
Panel that's on the custom control.

How do I change this behaviour?

Thanks in advance for any info,
Bram
 
this has been discussed a number of times at the designtime ng, try to
search there...
 
For those who are looking for the answer - I found it out myself.
Actually it's quite easy. All you have to do is create a custom
designer that derives of ParentControlDesigner. This Designer has a
method EnableDesignMode that allows enabling the DesignMode for sibling
controls.

using System.Windows.Forms.Design;

[Designer(typeof(MyUserControlDesigner))]
public class MyUserControl : UserControl {
[ ... ]

public Panel Panel1 {
}

public Panel Panel2 {
}
}


public class MyUserControlDesigner: ParentControlDesigner {
public override void Initialize(System.ComponentModel.IComponent
component) {
base.Initialize(component);
MyUserControl uc = component as MyUserControl;
EnableDesignMode(uc.Label1, uc.Label1.Name);
EnableDesignMode(uc.Label2, uc.Label2.Name);
}
}
 
Back
Top