0

How do i reverse the order of a combobox. I'm currently loading cboItems.items.add (reader.readline) from a .txt document using streamreader.

After the items are loaded into the Combobox, i want to reverse their order from Bottom to Top.

Is that possible?...

3
Contributors
2
Replies
4
Views
10 Years
Discussion Span
Last Post by hollystyles
0

Use an ArrayList, then iterate backwards

using System;
using System.Collections;
using System.IO;

namespace SortedList
{
    class Program
    {
        static void Main(string[] args)
        {
            ArrayList stringList = new ArrayList();

            StreamReader stringReader = new StreamReader("c:\\OptionList.txt");
            string option = "";

            while ((option = stringReader.ReadLine()) != null)
            {
                stringList.Add(option);
            }

            stringReader.Close();
            stringReader.Dispose();

            stringList.TrimToSize();

            for (int i = stringList.Count - 1; i >= 0; --i)
            {
                Console.WriteLine(stringList[i]);
            }

            Console.ReadLine();
        }
    }
}

You'll have to translate to VB syntax cos I can't stand VB syntax it makes my teeth jangle! And besides gotta leave you with something to do.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.