Open In App

How to set the Visibility of ListBox in C#?

In Windows Forms, ListBox control is used to show multiple elements in a list, from which a user can select one or more elements and the elements are generally displayed in multiple columns. In ListBox, you can set the visibility of the ListBox using Visible Property of the ListBox.
If the value of this property is set to true, then the Listbox control and its child control are visible on the screen and if the value of this property is set to false, then the Listbox control and its child control are not visible on the screen. The default value of this property is true. You can set this property in two different ways:

1. Design-Time: It is the easiest way to set the visibility of the ListBox as shown in 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 ListBox control programmatically with the help of given syntax:



public bool Visible { get; set; }

Here, the value of this property is of System.Boolean type. The following steps show how to set the visibility of the ListBox dynamically:


Article Tags :
C#