PDA

View Full Version : c# items combobox to listbox



mustang29
January 31st, 2007, 12:13 PM
does anyone know how I can put the items of a combobox into a listbox?

thx

kirupa
February 3rd, 2007, 02:21 PM
Are you using WinForms or WPF?

mustang29
April 4th, 2007, 06:17 AM
I work with winForms

kirupa
April 4th, 2007, 10:08 PM
In that case, let's say your Combobox is called cmbBox and your Listbox is called lstBox. The code for displaying all of the items from the Combobox into the Listbox would be:


for (int i = 0; i < cmbBox.Items.Count; i++)
{
lstBox.Items.Add(cmbBox.Items[i]);
}

=)