You may use the property DesignMode
to determine if your control is in design mode to draw the Rectangle
around it, otherwise at runtime, the rectangle will not be drawn.
public class CustomControl : UserControl
{
protected override void OnPaint(PaintEventArgs e)
{
if (DesignMode){
e.Graphics.DrawRectangle(Pens.Black, new Rectangle(0,0,ClientSize.Width-1, ClientSize.Height-1));
}
base.OnPaint(e);
}
}