---
title: "ListBox Control in C#.Net"  
description: "ListBox stores several text items. It can interact with other controls, including Button controls. We use this control in Windows Forms. In the exampl"  
author: "Anonymous User"  
published: 2011-01-24  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/395/listbox-control-in-c-sharp-dot-net  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# ListBox Control in C#.Net

ListBox stores several text items. It can interact with other controls, including Button controls. We use this control in Windows Forms. In the example program it interacts with two Buttons—through the Button Click event handler.\

##### Drag and drop ListBox from toolbox on the window Form.

![ListBox Control in C#.Net](https://www.mindstick.com/mindstickarticle/642ad6c6-b89f-49f9-bd2b-9604dd5ae7ee/images/9a3b3490-265f-4732-af8e-9831808435ce.png)

##### Code:

```
using System;using System.Text;using System.Windows.Forms;  namespace WindowsFormsApplication1{     public partial class frmListBox : Form    {         public frmListBox()         {            InitializeComponent();         }         private void frmListBox_Load(object sender, EventArgs e)         {            // Add item in ListBox            listBox1.Items.Add("C#");            listBox1.Items.Add("J#");            listBox1.Items.Add("VB");            listBox1.Items.Add("Java");         }     private void listBox1_SelectedIndexChanged(object sender, EventArgs e)         {            // selected value will show in Label     label3.Text ="Selected Language is "+listBox1.SelectedItem.ToString();         }    }}
```

\

![ListBox Control in C#.Net](https://www.mindstick.com/mindstickarticle/642ad6c6-b89f-49f9-bd2b-9604dd5ae7ee/images/084290b0-d0bb-4599-b56a-1d289bb0e85b.png)

##### Run The Project

![ListBox Control in C#.Net](https://www.mindstick.com/mindstickarticle/642ad6c6-b89f-49f9-bd2b-9604dd5ae7ee/images/0ed5d1d1-c630-4ea5-9c1d-7257a07ce89a.png)

##### When you select given option then SelectedIndexChanged event will fire and

##### selected Item will show in the Label.

![ListBox Control in C#.Net](https://www.mindstick.com/mindstickarticle/642ad6c6-b89f-49f9-bd2b-9604dd5ae7ee/images/e57900b2-9a9f-428b-ad6d-614df924445d.png)

##### ListBox Control Properties

Sorted: ListBox can be sorted through ListBox sorted Property

##### Example:

```
private void frmListBox_Load(object sender, EventArgs e){             //sorted ListBox Item    listBox1.Sorted = true;}
```

## ![ListBox Control in C#.Net](https://www.mindstick.com/mindstickarticle/642ad6c6-b89f-49f9-bd2b-9604dd5ae7ee/images/352f0ee7-6d68-4645-80e8-467da9c5fc11.png)

##### ListBox Item is sorted.

**BackColor:** ListBox Color can be changed through ListBox BackColor Property.

##### Example:

```
private void frmListBox_Load(object sender, EventArgs e){       //change ListBox BackColor       listBox1.BackColor = Color.CadetBlue;}
```

\

![ListBox Control in C#.Net](https://www.mindstick.com/mindstickarticle/642ad6c6-b89f-49f9-bd2b-9604dd5ae7ee/images/64c3a62c-f6ef-43e7-86a9-d942731d68db.png)

##### ListBox BackColor will be change when Application Run.

**ForeColor:** ListBox Fore color is changed through ListBox ForeColor Property.

## Example:

```
private void frmListBox_Load(object sender, EventArgs e){      //change ListBox ForeColor       listBox1.ForeColor = Color.Red;}
```

\

![ListBox Control in C#.Net](https://www.mindstick.com/mindstickarticle/642ad6c6-b89f-49f9-bd2b-9604dd5ae7ee/images/ec81661f-3c42-42c5-8374-f5f40c441ba9.png)

---

Original Source: https://www.mindstick.com/articles/395/listbox-control-in-c-sharp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
