---
title: "Update a listbox from another listbox"  
description: "Update a listbox from another listbox"  
author: "Anonymous User"  
published: 2014-01-25  
updated: 2014-01-25  
canonical: https://www.mindstick.com/forum/1874/update-a-listbox-from-another-listbox  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Update a listbox from another listbox

I have two Winforms (admForm and projForm) and each have a [listbox](https://www.mindstick.com/articles/626/listbox-events-in-c-dot-net). Inside the admForm you can [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) a [user](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) in the list box that belongs to this form.

Everything [works fine](https://answers.mindstick.com/qa/115732/my-software-works-fine-on-windows-10-but-crashes-on-windows-11-why) so far, but I would like to [update](https://www.mindstick.com/forum/156353/what-is-hummingbird-update) the listbox in "projForm" with [objects](https://www.mindstick.com/forum/145447/what-are-objects) that are in the list box in "admForm".

Any idea?

## In admForm:

```
public string ListBox{    get { return lstUserOrProject.Items.ToString(); }}
```

## In projForm:

```
private void UpdateList(){    AdminForm admForm = new AdminForm();    lstAvailableUser.Items.Add(admForm.ListBox.ToString());}
```

**[Code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) to open the projForm:**

```
    private void btnAdd_Click(object sender, EventArgs e)    {        int index = lstUserOrProject.SelectedIndex;        switch (cmbUserOrProject.SelectedIndex)        {            case (int)UserOrProject.Projects:                ProjectForm proj = new ProjectForm("Add Project");                if (proj.ShowDialog() == DialogResult.OK)                {                    projMngr.AddProject(proj.ProjectData);                    UpdateProject();                }                break;            case (int)UserOrProject.Users:                UserForm user = new UserForm("Add User");                if (user.ShowDialog() == DialogResult.OK)                {                    userMngr.AddUser(user.UserData);                    UpdateUser();                }                break;        }    }
```

## Replies

### Reply by Pravesh Singh

Hi samuel.

AdminForm admForm = new AdminForm();

You are creating completely new instance.

If you are open your projForm after your AdminForm, when you are showing your form use this code:

ProjForm projForm = new ProjForm(); // change ProjForm if your form class name is different

projForm.Show(this);

Then in your projForm you can access your listBox like this:

```
private void UpdateList(){  var items = Owner.lstUserOrProject.Items; // Owner represents your admin form  lstAvailableUser.Items.Clear();   foreach(var item in items)   {      lstAvailableUser.Items.Add(item);   } }
```

## Update:

Move this definition to the top of your page in AdminForm, i mean:

```
class AdminForm : Form{   // move your definition here   ProjForm projForm = new ProjForm();  // change ProjForm if your form class name is different}
```

Then when you want to show your form call:

projForm.Show(this);

When you want to update your list in the projform call your update method:

projForm.UpdateList();


---

Original Source: https://www.mindstick.com/forum/1874/update-a-listbox-from-another-listbox

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
