Have an amazing solution built in RAD Studio? Let us know. 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   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

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

Learn How to Use The MQTT Protocol in Delphi With This Library

CodeDatabaseDelphiRAD Studio

Flexible InterBase AdminUtility Sample Tours You Through Powerful InterBase Features

CodeDelphiRAD Studio

Learn How To Migrate dbExpress To FireDAC With The reFind Tool In This Delphi Sample

CodeDelphiRAD Studio

FireDAC Tip: Write Database Independent SQL Commands With Escape Functions

Leave a Reply

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

IN THE ARTICLES