Hey,

I am working on this small project that will shuffle an array of names and then will load them into 5 list boxes. I have 25 names and need to load 5 names per listbox. Need some suggestions on how would i go about accomplishing someting like this. Thanks!

Hi, I would use something like this, but I'm sure there are much better ways doing it.

string[] names = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i","j", "k" };
            int element = 0;
            List<ListBox> list = new List<ListBox>();
            list.Add(listBox1);
            list.Add(listBox2);
            list.Add(listBox3);
            list.Add(listBox4);
            list.Add(listBox5);
            while ( element < names.Length )
            {
                foreach ( ListBox lb in list )
                {
                    if ( element >= names.Length ) 
                        break;
                    lb.Items.Add(names[ element++ ].ToString());
                }
            }

Hope it helped :)

Thanks alot man, this helped alot. Now i have some extra time to tweak with the program.:)

I'm glad it worked ;) don't forget to mark the thread as solved :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.