RAD Studio VCL Reference
|
Specifies whether the items in a list box are arranged alphabetically.
property Sorted: Boolean;
__property Boolean Sorted;
Use Sorted to sort the items by setting its value to true. If Sorted is false, the items are unsorted. When Sorted is true, items are automatically added or inserted into the list box in alphabetical order.
C++ Examples:
/* This example uses an edit box, a list box, and two buttons on a form. The buttons are named Add and Sort. When the user clicks the Add button, the text in the edit box is added to the list in the list box. Before the user clicks the sort button, any new items are added to the end of the list. After the user clicks the Sort button, the list in the list box is sorted and remains sorted, even if additional strings are added. If the user clicks the sort button again, the list box remains sorted, but any new strings are again added to the end of the list. */ void __fastcall TForm1::FormCreate(TObject *Sender) { ListBox1->Items->Add("Not"); ListBox1->Items->Add("In"); ListBox1->Items->Add("Alphabetical"); ListBox1->Items->Add("Order"); } void __fastcall TForm1::AddClick(TObject *Sender) { ListBox1->Items->Add(Edit1->Text); } void __fastcall TForm1::SortClick(TObject *Sender) { ListBox1->Sorted = True; }
Delphi Examples:
{ This example uses an edit box, a list box, and two buttons on a form. The buttons are named Add and Sort. When the user clicks the Add button, the text in the edit box is added to the list in the list box. Before the user clicks the sort button, any new items are added to the end of the list. After the user clicks the Sort button, the list in the list box is sorted and remains sorted, even if additional strings are added. If the user clicks the sort button again, the list box remains sorted, but any new strings are again added to the end of the list. } procedure TForm1.FormCreate(Sender: TObject); begin ListBox1.Items.Add('Not'); ListBox1.Items.Add('In'); ListBox1.Items.Add('Alphabetical'); ListBox1.Items.Add('Order'); end; procedure TForm1.AddClick(Sender: TObject); begin ListBox1.Items.Add(Edit1.Text); end; procedure TForm1.SortClick(Sender: TObject); begin ListBox1.Sorted := True; end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|