Open In App

How to set the Foreground Color of a 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 are allowed to set the foreground color of the ListBox using ForeColor Property of the ListBox which makes your ListBox more attractive. You can set this property in two different ways:

1. Design-Time: It is the easiest way to set the foreground color of the ListBox as shown in the following steps:



2. RunTime: It is a little bit trickier than the above method. In this method, you can set the foreground color of the ListBox control programmatically with the help of given syntax:



public override System.Drawing.Color ForeColor { get; set; }

Here, Color indicates the foreground color of the ListBox. The following steps show how to set the foreground color of the ListBox dynamically:


Article Tags :
C#