Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
CodeDatabaseDelphiRAD Studio

Learn How To Customize The ListView Detail Text In A List Item With Delphi

The Sample is using the “Custom” list view item appearance value and configuring the appearance properties of list view items at design time. It also shows how to do this at run time.

When you run the application, it shows a list view. Each list item shows a detail text under its main label.

Tap the Set Properties button to change the appearance of the list view at run time. Tap the ToggleEditMode button to have the list view enter a selection edit mode where you can select several items. The buttons at the bottom, LiveBindings and Fill in Code, let you fill the list view with items defined using LiveBindings or defined at run time, respectively.

Location

You can find the ListViewCustomBottomDetail Sample sample project at:

  • Start | Programs | Embarcadero RAD Studio Sydney | Samples and navigate to:
    • Object PascalMulti-Device SamplesUser InterfaceListViewListViewCustomBottomDetail
    • CPPMulti-Device SamplesUser InterfaceListViewListViewCustomBottomDetail
  • 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.

How to Use the Sample

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

Implementation

The values of the ItemAppearance.ItemAppearance and ItemAppearance.ItemEditAppearance properties of the list view in this application are “Custom”. This indicates that, instead of using a default appearance set, the appearance objects of the item appearance are customized. They have been customized at design time, selecting appearance objects in the Structure view and changing their properties from the Object Inspector.

By default, the base custom appearance only has one visible appearance object: Text. That is, Text is the only visible appearance object in TListView.ItemAppearance.Item and TListView.ItemAppearance.ItemEdit. This application makes visible the following appearance objects as well, and configures their properties to customize their appearance:

In addition to these design time changes, this application handles the OnUpdateObjects event of the list view to adjust the width of the Text and Detail appearance objects.

The Set Properties button, when tapped, modifies the appearance of the list view at run time, performing appearance adjustment on top of the custom appearance defined at design time.

The LiveBindings button uses TLinkFillControlToField to fill the list view using LiveBindings. The Fill in Code button uses a for loop to fill the list view with items created at run time.

You can follow the link below which will guide you to the original post of the Sample:

http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FMX.ListViewCustomBottomDetail_Sample

Head over and check out the full source code for customizing the listview detail of a listitem in Delphi.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES