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

Have You Made Your Application Server HTTP/2 Ready?

CodeDelphiIDERAD Studio

Cartoonify Photos With This Easy But Powerful Neural Network

CodeDelphiRAD Studio

Easily Automate The DigitalOcean API From Windows And Mobile

C++Delphi

Easily Deploy RAD Server With Windows And Linux Installers

Leave a Reply

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

IN THE ARTICLES