Changing the Border Color of Windows Form Controls

Windows forms application doesn’t allow you change the border color of the controls out of the box. However, this can be achieved by overriding the paint event of the control. Below is the sample for applying the border color for a label.

 
       private void Label1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawRectangle(new Pen(Color.Red), new Rectangle(0, 0, ((Label)sender).Width - 1, ((Label)sender).Height - 1));
        }
 

Similar way, you can change the appearance of any control the way you want to.

clip_image002

Thumbs up

  Shared by : Jebarson Jabamony


DON'T MISS OUT!
Subscribe To Newsletter For your Daily Development Tips and Tricks  

 Best Tips & Tricks on Microsoft Technology Platform 

Invalid email address
We promise not to spam you. You can unsubscribe at any time.
Jebarson

Jebarson is a consultant at Microsoft. In his overall experience of 7+ years, his expertise ranges from VB6, COM / DCOM, .net, ASP.net, WPF, WCF, SL, SQL. He has a greater love for OOA / OOD and SOA. His current focus is on Azure, Windows Phone 7, Crm and much more. He is also a frequent speaker of different community events. He blogs at http://www.jebarson.info/ . You can follow him at @Jebarson007 . Jebarson having good set of tutorials written on Windows Azure, you can found them http://bit.ly/houBNx . He is a contributor of this site and shared many tips and tricks.

One Comment to “Changing the Border Color of Windows Form Controls”

Comments are closed.