XE3 Visual LiveBindings: TListView

Posted by on in Blogs
A previous post uses TListBox to demonstrate how to link fields to a list control.  The same steps can be used to link fields to TListView.

Here is a sample form with a TListView:



To improve the TListView appearance, the ListView1.ViewStyle property has been set to vsList.

The LiveBindings designer looks like this:



A project containing this form can be downloaded here.  See SimpleListView.dpr.

The LiveBindings designer also supports TListView columns.  Follow these steps to add columns to ListView1:

  1. Select ListView1

  2. View the object inspector

  3. Use the object inspector to change properties of ListView1

    • Change ListView1.ViewStyle to vsReport

    • Click on the "..." to the right of the ListView1.Columns property to show the columns editor

    • Use the columns editor to add three columns




The LiveBindings designer shows additional member for ListView1:

"Item.Caption" is the only member linked to a field, so the form looks like this:



To improve the TListView appearance,  use the object inspector to set column captions and widths.

To fill the additional columns, add two fields to TPrototypeBindSourceFill and connected the new fields to the "SubItems" members.

After these changes, the form looks like this:



The design looks like this:



A project containing this form can be downloaded here.  See ListViewColumns.dpr.


Comments

Check out more tips and tricks in this development video: