This site hosted by Free.ProHosting.com
Google

How can I sort items alphabetically?

Applies To: C++Builder 1 or higher
Category: Knowledge Base

 
 1.
  Start a new project using File | New Application.
 
 2.
  Add a ListBox.
 
 3.
  Add two (2) Buttons. Set their OnClick event to:
 
void __fastcall TForm1::Button1Click(TObject *Sender)
{
    ListBox1->Items->Add("C");
    ListBox1->Items->Add("A");
    ListBox1->Items->Add("W");
    ListBox1->Items->Add("T");
}
 
void __fastcall TForm1::Button2Click(TObject *Sender)
{
    ListBox1->Sorted = true;
}
 
When Sorted is true, items that are added or inserted are in alphabetical order.
 
Tips
· If you only want to sort current items, use the Sort method.

C++Builder Developer's Network
Copyright © Yoto Yotov