Vcl.StdCtrls.TCustomCombo.Items

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

property Items: TStrings read FItems write SetItems;

C++

__property System::Classes::TStrings* Items = {read=FItems, write=SetItems};

Properties

Type Visibility Source Unit Parent
property public
Vcl.StdCtrls.pas
Vcl.StdCtrls.hpp
Vcl.StdCtrls TCustomCombo

Description

Provides access to the list of items (strings) in the list portion of the combo box.

Read Items to access the list of items that appears in the combo box. Use the methods of Items to add, insert, delete and move items. Set the value of Items to copy the items from another string list.

For example, for Vcl.DBCtrls.TDBComboBox, use Items to supply the values in the list from which the user can choose. Because Items is an object of type TStrings, you can add, delete, insert, and move items using the Add, Delete, Insert, Exchange, and Move methods of the TStrings object. For example, to add each string to the combo box list, write code such as the following:

while not CountryTbl.Eof do begin
  DBComboBox1.Items.Add(CountryTbl.FieldByName('Country').AsString);
  CountryTbl.Next;
end;
while (!CountryTbl->Eof)
{
  DBComboBox1->Items->Add(CountryTbl->FieldByName("Country")->AsString);
  CountryTbl->Next();
}

The ItemIndex property determines which item is selected, if any.

See Also

Code Examples