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.



About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist