Place a Colored Border on a Control

Place a Colored Border on a Control

Suppose you simply want to change the border color of a control to something other than black, so you looked for the BorderColor property in the Properties Window…but it’s not there.

There is actually a very easy answer to this problem, but you’re asking the wrong question. “How to give a control a colored border” is apparently very complicated, but “How to make a control APPEAR to have a colored border,” is mindlessly easy.

The answer is to put the control in a Panel.

Simply follow these steps:

  1. Add a Panel> to your form. Make sure the BorderStyle is None. Set BackColor to the color you want as a border, red, for example. Set Padding to 1,1,1,1 for a 1 pixel wide border.
  2. Draw the control you really want, a TextBox perhaps, inside the Panel. Set BorderStyle to None and Dock to Fill.
  3. When you want to move, hide, and/or whatever to the TextBox, do it to the Panel instead.

This technique will work with virtually any control. Rocket science it isn’t, but for most of us, it will get the job done. And best of all, you don’t have to add a single line of code.


  • Adjust the border width by changing the size of the Padding.
  • For a TextBox, if Multiline is False, you’ll have to adjust the Height of the Panel manually. For a 1 pixel wide border, set it be 2 greater than the Height of the TextBox.
  • If you use a Label instead of a Textbox, make sure you set AutoSize to False, and set the label’s BackColor to match the Form.


Share the Post: