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:
Share on facebook
Share on twitter
Share on linkedin


The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS