Open In App

How to style the Border of Label in C#?

In Windows Forms, Label control is used to display text on the form and it does not take part in user input or in mouse or keyboard events. You are allowed to style the border of the Label control using the BorderStyle Property. You can style the border of the label in three different ways and these values are provided by the BorderStyle enum:

The default value of this property is BorderStyle.None. You can set this property using two different methods:



1. Design-Time: It is the easiest method to set the BorderStyle property of the Label control using the following steps:

2. Run-Time: It is a little bit trickier than the above method. In this method, you can style the border of the Label control programmatically with the help of given syntax:

public virtual System.Windows.Forms.BorderStyle BorderStyle { get; set; }

Here, BorderStyle indicates border style values. It will throw an InvalidEnumArgumentException if the value assigned to this property does not belong to BorderStyle values. Following steps are used to set the BorderStyle property of the Label:


Article Tags :
C#