---
title: "Programmatically storing a list into my combobox's item collection"  
description: "Programmatically storing a list into my combobox's item collection"  
author: "Anonymous User"  
published: 2014-01-27  
updated: 2014-01-28  
canonical: https://www.mindstick.com/forum/1889/programmatically-storing-a-list-into-my-combobox-s-item-collection  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Programmatically storing a list into my combobox's item collection

I am working on a [Windows](https://www.mindstick.com/articles/311752/how-to-install-and-use-the-google-wifi-software-on-a-windows-or-mac-computer) Form [right now](https://answers.mindstick.com/qa/36863/what-would-happen-if-gravity-became-5-percent-stronger-right-now), specifically, a combo box.

I have two List<[string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp)>. Let's say the first List are names, and the second List are ages.

How does one store the entire first List into the [collection](https://www.mindstick.com/articles/1718/collections-in-java), so I can use the [comboBox](https://www.mindstick.com/articles/57/display-record-according-to-combobox-selection-in-csharp-dot-net) to [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) them?

Upon clicking on an item in this collection, for example, the fifth name, how do I get the index of this item?

So far, I have created my form, and laid the [skeleton](https://yourviews.mindstick.com/story/1558/facts-about-the-skeleton) of the win [forms application](https://www.mindstick.com/forum/33817/how-to-use-webbrowser-controls-in-windows-forms-application-c-sharp-dot-net), but the part of storing the list into the collection is stopping me from moving [forward](https://www.mindstick.com/forum/33488/in-webview-disabling-uitoolbar-s-back-and-forward-butttons)

thank you.

## Replies

### Reply by Pravesh Singh

Hi Chintoo,\

For the list of strings it can be done like this

```
comboBox.DataSource = myList;
```

If you don't want to tie your list in Datasource, still one line

```
comboBox.DataSource = myList.ToArray().Clone();
```

Now, if this is list of Strings you can get the whole string

```
string s = (string)comboBox.SelectedItem; // vs comboBox.SelectedIndex
```


---

Original Source: https://www.mindstick.com/forum/1889/programmatically-storing-a-list-into-my-combobox-s-item-collection

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
