Vcl.StdCtrls.TCustomListBox.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 TCustomListBox

Description

Contains the strings that appear in the list box.

Use Items to add, insert, delete and move items. By default, the items in a list box are of type TStrings. Use this item type to access its methods or properties to manipulate the items in the list.

For example, the following code snippet shows how to add the text in the edit box to the list box as an item:

  ListBox1.Items.Add(Edit1.Text);
  ListBox1->Items->Add(Edit1->Text);
Tip: If you have a list box with tab stops enabled (TabStop property) and you want to add data to specific columns, you can set the TabWidth property to obtain a list box in which individual lines can be displayed in columns, as long as they use tabs in their text, as shown in the snippet below (notice #9 is the tab character).
  ListBox1.TabWidth := 50;
  ListBox1.Items.Add('hi' + #9 + 'lo');
  ListBox1.Items.Add('foo' + #9 + 'bar');
  ListBox1.Items.Add('ki' + #9 + 'mo');

And the result would be:

TCustomListBox2.png

See Also

Code Examples