Home > DeveloperSection > Forums > Transferring data from one list box to another c#
Jeet Verma
Jeet Verma

Total Post:110

Posted on    December-12-2013 1:58 AM

 C# C# 

 1 Reply(s)
 968  View(s)
Rate this:

I have 2 list boxes one is connected to a database the other isnt.

I want to be able to send the selected item from the listbox connected to the database to the one that isnt.

Ive written this code


But instead of copyin the item i get "


Anyone having any advice?

Pravesh Singh

Total Post:411

Posted on    December-12-2013 2:28 AM

Hi Jeet,

This is the simplest way to load a listbox to another list box and at the same time remove the data from the sorce listbox

int mCount = ListBox1.Items.Count;

for (int i = 0; i <= mCount - 1; i++)


    if (ListBox1.Items[i] == ListBox1.SelectedItem)




        mCount=mCount - 1;

        i=i - 1;



Don't want to miss updates? Please click the below button!

Follow MindStick