Open In App

How to set the Visibility of the 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 set the visibility of the Label control using the Visible Property in the windows form. The label is visible when the value of this property is set to be true.
If the value of this property is set to be false, then the Label does not visible in the form. The default value of this property is true. You can set this property using two different methods:

1. Design-Time: It is the easiest method to set the Visible 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 set the visibility of the Label control in the windows forms programmatically with the help of given syntax:

public bool Visible { get; set; }

Here, the value of this property is of System.Boolean type. Following steps are used to set the Visible property of the Label:


Article Tags :
C#