FMX.SimpleListView Sample

From RAD Studio Code Examples
Jump to: navigation, search

This is a project that shows how to implement a Delete button that works with a "Select" edit mode of a TListView.

Location

You can find the SimpleListView Sample sample project at:

  • Start | Programs | Embarcadero RAD Studio Alexandria | Samples and navigate to:
    • Object Pascal\Multi-Device Samples\User Interface\ListView\SimpleListView
    • CPP\Multi-Device Samples\User Interface\ListView\SimpleListView
  • Subversion Repository:
    • You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.

Description

When you run the application, it shows a list view and an Edit button on top. You can tap the Edit button to enter edit mode.

In edit mode, a Delete button appears at the bottom of the application. You can select list items and then tap Delete to remove them from the list. Also, in edit mode the Edit button turns into a Done button that you can tap to return to display mode.

How to Use the Sample

  1. Navigate to the one of the locations given above, and open:
    • Delphi: SimpleListView.dproj
    • C++: SimpleListView.cbproj
  2. Press F9 or choose Run > Run.

Implementation

This application is based on a list view and three buttons: Edit, Delete and Done.

The Edit button is located at the top-right corner of the application. The application handles the OnClick event of this button, where it enables the edit mode of the list view, shows the Delete and Done buttons, and hides the Edit button.

The Delete button is located at the bottom-left corner of the application, and is hidden by default. The application handles the OnClick event of this button. This event handler deletes any selected list view item.

The Done button is located at the top-right corner of the application, overlapping at design time with the Edit button. However, Done is hidden by default. Edit and Done never overlap at run time. The application handles the OnClick event of the Done button as well. Its event handler disables the edit mode of the list view, shows the Edit button and hides the Delete and Done buttons.

Uses

See Also