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();
}
Share with