How do I prevent resizing of my Control in the designer?

You normally need this support when your Control is parented by another custom Container Control that manages the location and size of your Control. You can prevent resizing by overriding this method in your custom ControlDesigner class: protected override bool EnableDragRect { get { return false; } } Or, for more control over the resizing process: public override /*ControlDesigner*/ SelectionRules SelectionRules { get { System.Windows.Forms.Design.SelectionRules selectionRules; System.Windows.Forms.Control control; selectionRules = base.SelectionRules; control = this.Control; if (control.Parent is MyControlParent) selectionRules = (SelectionRules)(selectionRules & ~(SelectionRules.AllSizeable)); return selectionRules; } }

How can I know when a Control/Component has been selected in the designer surface?

You can listen to the SelectionChanged event in your Control Designer. public class MyContainerDesigner : ParentControlDesigner { public override /*ParentControlDesigner*/ void Initialize(IComponent component) { base.Initialize(component); iSelectionService = (ISelectionService)this.GetService(typeof(ISelectionService)); if (iSelectionService != null) iSelectionService.SelectionChanged += new EventHandler(this.OnSelectionChanged); } private void OnSelectionChanged(object sender, EventArgs e) { // To find out the current selection (can be more than 1) do this: System.ComponentModel.Design.ISelectionService iSelectionService; System.Collections.ICollection selectedComponents; this.iamSelected = false; iSelectionService = (ISelectionService)this.GetService(typeof(ISelectionService)); if (iSelectionService != null) { selectedComponents = iSelectionService.GetSelectedComponents(); foreach(object selectedComponent in selectedComponents) { if(selectedComponent == this.Component) this.iamSelected = true; } } } }

Can I do some custom drawing on my control designer’s surface during design-time?

Yes, you can. You have to override OnPaintAdornments in your Control Designer. This will be called after the Control has painted. A good example is when you have a Control that has its border style set to None, and you want to draw a dummy border in the designer. protected override /*ParentControlDesigner*/ void OnPaintAdornments(PaintEventArgs pe) { System.Windows.Forms.Panel panel; panel = (System.Windows.Forms.Panel)this.Component; if (panel.BorderStyle == BorderStyle.None) this.DrawDesignTimeBorder(pe.Graphics, panel); base.OnPaintAdornments(pe); } public void DrawDesignTimeBorder(Graphics g, Control control) { System.Drawing.Rectangle clientRectangle; System.Drawing.Color bgColor, adjustedBgColor; System.Drawing.Pen pen; clientRectangle = control.ClientRectangle; bgColor = control.BackColor; if (((double) bgColor.GetBrightness()) >= 0.5) adjustedBgColor = ControlPaint.Dark(control.BackColor); else adjustedBgColor = ControlPaint.Light(control.BackColor); pen = new Pen(adjustedBgColor); pen.DashStyle = DashStyle.Dash; clientRectangle.Width = (clientRectangle.Width – 1); clientRectangle.Height = (clientRectangle.Height – 1); g.DrawRectangle(pen,clientRectangle); pen.Dispose(); }