941,512 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 4018
  • VB.NET RSS
Apr 27th, 2007
0

VB.Net Combobox Reverse Order

Expand Post »
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?...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ScatterMap is offline Offline
2 posts
since Apr 2007
Apr 27th, 2007
0

Re: VB.Net Combobox Reverse Order

Yes it is possible.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Apr 27th, 2007
0

Re: VB.Net Combobox Reverse Order

Use an ArrayList, then iterate backwards

VB.NET Syntax (Toggle Plain Text)
  1. using System;
  2. using System.Collections;
  3. using System.IO;
  4.  
  5. namespace SortedList
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. ArrayList stringList = new ArrayList();
  12.  
  13. StreamReader stringReader = new StreamReader("c:\\OptionList.txt");
  14. string option = "";
  15.  
  16. while ((option = stringReader.ReadLine()) != null)
  17. {
  18. stringList.Add(option);
  19. }
  20.  
  21. stringReader.Close();
  22. stringReader.Dispose();
  23.  
  24. stringList.TrimToSize();
  25.  
  26. for (int i = stringList.Count - 1; i >= 0; --i)
  27. {
  28. Console.WriteLine(stringList[i]);
  29. }
  30.  
  31. Console.ReadLine();
  32. }
  33. }
  34. }

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.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Delete checked items from datagrid
Next Thread in VB.NET Forum Timeline: VB.NET ComboBox & Statusbar HELP!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC