I'm writing a graphical control that can have a border with a widt
of 1 to 10 pixels. My control is derived from System.Windows.Forms.Control
I would have expected the following method to
accomplish the task..
private void DrawBorder(Graphics g
using (Pen pen = new Pen(BorderColor, BorderWidth
pen.Alignment = PenAlignment.Inset
g.DrawRectangle(pen, this.ClientRectangle)
.... however, with a borderwidth of 1 pixel, the border is drawn
outside the control at the right and bottom sides. What I ende
up having to do is the following..
private void DrawBorder(Graphics g
using (Pen pen = new Pen(BorderColor, BorderWidth
int Offset = BorderWidth >> 1
g.DrawRectangle(pen, Offset, Offset
this.Width - BorderWidth
this.Height - BorderWidth)
Has anyone else come across funnies with Pen alignment??