---
title: "C# winform How to Add Color in ListBox"  
description: "C# winform How to Add Color in ListBox"  
author: "Tech Sys"  
published: 2014-10-13  
updated: 2014-11-05  
canonical: https://www.mindstick.com/forum/2373/c-sharp-winform-how-to-add-color-in-listbox  
category: ".net"  
tags: ["c#"]  
reading_time: 3 minutes  

---

# C# winform How to Add Color in ListBox

hi,\
could anybody help the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) for [listbox](https://www.mindstick.com/articles/626/listbox-events-in-c-dot-net) [color](https://www.mindstick.com/articles/77/how-to-split-form-background-color-in-c-sharp) [add](https://www.mindstick.com/forum/12983/add-address-in-textbox-when-page-is-load-and-if-i-search-address-in-textbox-show-in-map-by-javascript) (like add fill rectangle with [name](https://yourviews.mindstick.com/view/87450/how-to-generate-a-brand-name-using-linkedin-comprehensive-guide)).plz [ref](https://www.mindstick.com/interview/217/what-is-the-difference-between-ref-out-parameters) below [image](https://www.mindstick.com/articles/23551/an-investigate-distinctive-seafood-restaurant-for-your-image-stamp-character)![C# winform How to Add Color in ListBox](https://www.mindstick.com/mindstickforums/9b1b96c5-7f3f-4d43-89ce-a7209e2670ed/images/296c93ac-cd6e-4dcb-a679-f7ec9db58c16.png)\
\
thanks in advance

## Replies

### Reply by Tech Sys

Hi John Smith\
i dont know how to implimented.actually iam newso plz help the code.how to user add color to listbox.give us any example which is nearest to my requirement or help us same what i need.\
thanks\

### Reply by John Smith

Please explain your requirement....and paste your code here...\
Let us see your code.\

### Reply by Tech Sys

thanks Kamlakar,\
But this is not my require,i want add like draw fill rectangle list add in listbox\
rgds\

### Reply by Anonymous User

try this:

```
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using System.Collections;using System.IO; namespace listboxcolor{    public partial class Form1 : Form    {        private System.Collections.Specialized.StringCollection folderCol;         private System.Windows.Forms.ImageList ilLarge;        private System.Windows.Forms.ImageList ilSmall;        private System.Windows.Forms.ListView lwFilesAndFolders;        private System.Windows.Forms.Label lblCurrentPath;        public Form1()        {            InitializeComponent();            folderCol = new System.Collections.Specialized.StringCollection();            CreateHeadersAndFillListView();            PaintListView();         }        private void CreateHeadersAndFillListView()        {            ColumnHeader colHead;             colHead = new ColumnHeader();            colHead.Text = "S/N";            this.lwFilesAndFolders.Columns.Add(colHead);             colHead = new ColumnHeader();            colHead.Text = "Color Name";            this.lwFilesAndFolders.Columns.Add(colHead);             colHead = new ColumnHeader();            colHead.Text = "Color View";            this.lwFilesAndFolders.Columns.Add(colHead);        }         private void PaintListView()        {            ListViewItem lvi;            ListViewItem.ListViewSubItem lvsi;             try            {                 string[] color = {"Gray"};                for (int i = 0; i <= color.Length; i++)                {                    lvi = new ListViewItem();                    lvi.Text = "" + i;                     lvsi = new ListViewItem.ListViewSubItem();                    lvsi.Text = color[i];                    lvi.SubItems.Add(lvsi);                     lvsi = new ListViewItem.ListViewSubItem();                    lvi.SubItems.Add(lvsi);                     this.lwFilesAndFolders.Items.Add(lvi);                     lwFilesAndFolders.Items[0].UseItemStyleForSubItems = false;                    lwFilesAndFolders.Items[0].SubItems[2].BackColor = Color.Gray;                 }            }            catch (System.Exception err)            {                MessageBox.Show("Error: " + err.Message);            }             this.lwFilesAndFolders.View = View.Details;                    }    }}
```

Form1.Designer.cs:

```
private void InitializeComponent()        {            //      System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));            this.lblCurrentPath = new System.Windows.Forms.Label();            this.ilLarge = new System.Windows.Forms.ImageList();            this.ilSmall = new System.Windows.Forms.ImageList();            this.lwFilesAndFolders = new System.Windows.Forms.ListView();            this.SuspendLayout();             this.lblCurrentPath.Location = new System.Drawing.Point(16, 8);            this.lblCurrentPath.Name = "lblCurrentPath";            this.lblCurrentPath.Size = new System.Drawing.Size(528, 16);            this.lblCurrentPath.TabIndex = 3;            //             // ilLarge            //             this.ilLarge.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;            this.ilLarge.ImageSize = new System.Drawing.Size(32, 32);            //      this.ilLarge.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ilLarge.ImageStream")));            this.ilLarge.TransparentColor = System.Drawing.Color.Transparent;            //             // ilSmall            //             this.ilSmall.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;            this.ilSmall.ImageSize = new System.Drawing.Size(16, 16);            //      this.ilSmall.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ilSmall.ImageStream")));            this.ilSmall.TransparentColor = System.Drawing.Color.Transparent;            //             // lwFilesAndFolders            //             this.lwFilesAndFolders.LargeImageList = this.ilLarge;            this.lwFilesAndFolders.Location = new System.Drawing.Point(16, 32);            this.lwFilesAndFolders.MultiSelect = false;            this.lwFilesAndFolders.Name = "lwFilesAndFolders";            this.lwFilesAndFolders.Size = new System.Drawing.Size(400, 216);            this.lwFilesAndFolders.SmallImageList = this.ilSmall;            this.lwFilesAndFolders.TabIndex = 0;            this.lwFilesAndFolders.View = System.Windows.Forms.View.List;            //             // Form1            //             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);            this.ClientSize = new System.Drawing.Size(552, 293);            this.Controls.AddRange(new System.Windows.Forms.Control[] { this.lblCurrentPath, this.lwFilesAndFolders });            this.Name = "Form1";            this.Text = "ListView";            this.ResumeLayout(false);         }
```


---

Original Source: https://www.mindstick.com/forum/2373/c-sharp-winform-how-to-add-color-in-listbox

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
