Trying to change the Border Color of a label

Stewbob picture Stewbob · Jun 12, 2009 · Viewed 31.2k times · Source

I'm working in VB, VS2008, winforms. I've got some labels to create, and I'm using the BorderStyle = FixedSingle.

Is there any way to change the color of this border? It is always defaulting to black.

Answer

orandov picture orandov · Jun 12, 2009

If you don't want to create a custom control you can try this:

Hook up to the Label's paint event.

void label1_Paint(object sender, PaintEventArgs e)
{
    ControlPaint.DrawBorder(e.Graphics, label1.DisplayRectangle, Color.Blue, ButtonBorderStyle.Solid);
}

Taken from here by Andrej Tozon