RAD Studio 10.4.1 is now available! Learn more. Looking for discounts? Visit our Special Offers page!
C++

Adding headers to TListView programmatically

During today’s Delphi, C++Builder and RAD Studio 10 Seattle launch webinar, I got a question on how to add headers to TListView programmatically instead of using LiveBindings with a data source.

Here is a quick code snippet showing how to programmatically add TListView headers.

procedure TListViewHeaders.FormCreate(Sender: TObject);
var
  Group, Item: Integer;
begin
  for Group in [1..4] do
  begin
    with ListView1.Items.Add do
    begin
      Text := Format('Header %d', [Group]);
      Purpose := TListItemPurpose.Header;
    end;
     for Item in [1..10] do
     ListView1.Items.Add.Text := Format('Regular item %d.%d', [Group, Item]);
  end;
end;

 

rad_studio_seattle_banner_680x150px_cta_try_now-1856316


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

About author

Director of Product Management, Developer Tools Idera, Inc.
Related posts
CodeDelphiRAD Studio

Learn How To Use Connection Pooling With A Multi-threaded Environment In Delphi

CodeDatabaseDelphiRAD Studio

Quickly Share Data Between Datasets Using CloneCursor In This Native Windows Sample For Delphi

CodeDelphiRAD Studio

Powerful Optical Barcode Recognition Component For Delphi Firemonkey By Winsoft

RAD StudioTech Partner

Powerful Live Local And Remote Application Logging With CodeSite Express In Delphi

Leave a Reply

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

IN THE ARTICLES