Grouping in a listview

  with ListView1 do
  begin
    GroupView := True;
    GroupHeaderImages := ImageList1;
    with Groups.Add do
    begin
      Header := 'Group1';
      Footer := 'This is group0''s footer';
      GroupID := 0;
      State := [lgsNormal,lgsCollapsible];
      HeaderAlign := taLeftJustify;
      FooterAlign := taLeftJustify;
      Subtitle := 'This is group0''s subtitle' ;
      TitleImage := ImageList1.Count - 1;
    end;
    with Groups.Add do
    begin
      Header := 'Group2';
      Footer := 'This is group1''s footer';
      GroupID := 1;
      State := [lgsNormal,lgsCollapsible];
      HeaderAlign := taLeftJustify;
      FooterAlign := taLeftJustify;
      Subtitle := 'This is group1''s subtitle' ;
      TitleImage := ImageList1.Count - 2;
    end;

    LargeImages := ImageList1;
    for i := 0 to ImageList1.Count - 3 do
    begin
      with Items.Add do
      begin
        ImageIndex := i;
        GroupID := i div 4;
        Caption := Format('Group:%d ImageIndex: %d',[GroupID,i]) ;
      end;
    end;
  end;
end;
原文地址:https://www.cnblogs.com/cxp2009/p/2271025.html