---
title: "Refresh a listbox to display new values"  
description: "Refresh a listbox to display new values"  
author: "Royce Roy"  
published: 2013-09-04  
updated: 2013-09-04  
canonical: https://www.mindstick.com/forum/1453/refresh-a-listbox-to-display-new-values  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Refresh a listbox to display new values

## Hi Guys

I'm [filling](https://yourviews.mindstick.com/audio/1303/the-power-of-silence-what-happens-when-you-stop-filling-every-moment) out my [text](https://www.mindstick.com/blog/301635/did-people-reinvent-texting-to-express-the-full-range-of-emotions) box with [values](https://www.mindstick.com/forum/327/sum-textbox-values) Im grabbing on line and passing them to the [listbox](https://www.mindstick.com/articles/626/listbox-events-in-c-dot-net) like so:\

```
        // textBox1.Text = test.ToString();        string[] names = result.Split('|');        foreach (string name in names)        {            listBox1.Items.Add(name);        }
```

However I'm [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to [click](https://www.mindstick.com/articles/12423/social-login-magento-2-one-click-to-register-social) on a folder and have the [files](https://www.mindstick.com/articles/23302/the-importance-and-advantage-of-keeping-your-important-files-on-the-cloud) displayed from there be shown in my listbox1. THis is what I've tried:

```
   using (var testy = new WebClient())        {            test = testy.DownloadString("http://server.foo.com/images/getDirectoryList.php?dir=test_folder");            string[] names1 = test.Split('|');            foreach (string name in names1)            {                listBox1.Items.Clear();                listBox1.Items.Add(name);                listBox1.Update();            }        }
```

**But all that happens is that my listbox empties and doesn't get refreshed.**

## Replies

### Reply by Sumit Kesarwani

Hi Royce,\

Use a BindingSource

```
BindingSource bs = new BindingSource();List<string> names1 = new List();bs.DataSource = names1;comboBox.DataSource = bs;   using (var testy =
new WebClient())    {        test =
testy.DownloadString("http://server.foo.com/images/getDirectoryList.php?dir=test_folder");       
names1.AddRange(test.Split('|'));       
bs.ResetBindings(false);    }
```

The BindingSource will take care of everything for you.


---

Original Source: https://www.mindstick.com/forum/1453/refresh-a-listbox-to-display-new-values

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
