Show: Delphi C++
Display Preferences

FMX.ListView.TListView

From RAD Studio API Documentation
Jump to: navigation, search

FMX.ListView.TCustomListViewFMX.Controls.TStyledControlFMX.Controls.TControlFMX.Types.TFmxObjectSystem.Classes.TComponentSystem.Classes.TPersistentSystem.TObject
TListView

Delphi

TListView = class(TCustomListView)

C++

class PASCALIMPLEMENTATION TListView : public TCustomListView

Contents

Properties

Type Visibility Source Unit Parent
class public
FMX.ListView.pas
FMX.ListView.hpp
FMX.ListView FMX.ListView

Description

Represents a FireMonkey list view component that you can use to hold and present various types of items.

The TListView displays a collection of items in a list that is optimized for LiveBindings and for fast and smooth scrolling.

The items in the list view can have one or more of the following appearance features:

  • A caption or detail text (for example, using the Item.Text bindable member of TListView)
  • An associated image (for example, using the Item.Bitmap bindable member of TListView)
  • An accessory icon (for example, using the ItemEditAppearance property in the Object Inspector)
  • A graphic or a text button attached (for example, using the Item.ButtonText bindable member of TListView)

Enabling the Swipe-to-Delete Feature on TListView Items

When the Swipe-to-Delete feature is enabled, the end user can swipe an item in a list view, and a Delete button temporarily appears on the item. The user can then click the Delete button to delete the item from the list view, or release the swipe to retain the item in the list view. This feature works on mobile (that is, iOS and Android), and, when touch input is enabled, on desktop apps as well (Mac OS X and Windows).

To set the swipe-to-delete feature on TListView items, set the CanSwipeDelete property to True.

Example

You can add items to a TListView either by binding to a data source, or by code (ListViewItems.Add).

Here is a code example that shows how to add items to a TListView:

Delphi:

var
  LItem: TListViewItem;
  I: Integer;
begin
  for I := 1 to 10 do
  begin
    LItem := ListView1.Items.Add;
    LItem.Text := IntToStr(I); 
 end;
end;
 
// To achieve the best performance use BeginUpdate and EndUpdate.
 
var
  LItem: TListViewItem;
  I: Integer;
begin
  ListView1.BeginUpdate;
  try
    for I := 1 to 10 do
    begin
      LItem := ListView1.Items.Add;
      LItem.Text := IntToStr(I);
    end;
  finally
    ListView1.EndUpdate;
  end;
end;

C++:

for (int i = 1; i <= 10; i++) {
  TListViewItem* item = ListView1->Items->Add();
  item->Text = IntToStr(i);
}
 
// To achieve the best performance use BeginUpdate and EndUpdate.
 
ListView1->BeginUpdate();
try {
  for (int i = 1; i <= 10; i++) {
    TListViewItem* item = ListView1->Items->Add();
    item->Text = IntToStr(i);
  }
} catch (...) {
}
ListView1->EndUpdate();

See Also

Personal tools
Translations