I want to get an bunch of items from a list box, add them to an array, sort it, then put it back into a different listbox. Here is what I have came up with:
ArrayList q = new ArrayList();
foreach (object o in listBox4.Items)
q.Add(o);
q.Sort();
listBox5.Items.Add(q.ToString());
But it doesnt work. Any ideas?
Try this:
If you need it to sort by the Values, just switch out item.Text with item.Value.
Enjoy!
Add the items to array and close the loop. Then sort the array values and bind it to listbox
also you can use "extension methods" that i wrote: