Update Delphi XE4 1 and Windows 8.
When I add groups and elements to the list view, they are displayed correctly. When I clear elements and groups and add them again, nothing appears. Is this not supposed behavior?
From DFM:
object lv: TListView
Left = 24
Top = 20
Width = 250
Height = 225
Columns = <
item
Caption = 'Model'
Width = 180
end>
GroupView = True
ReadOnly = True
RowSelect = True
TabOrder = 0
ViewStyle = vsReport
end
The code:
procedure TForm1.Button1Click(Sender: TObject);
var
LListGroup: TListGroup;
LListItem: TListItem;
begin
lv.Items.Clear;
lv.Groups.Clear;
LListGroup := lv.Groups.Add;
LListGroup.Header := 'Ford';
LListItem := lv.Items.Add;
LListItem.Caption := 'Escape';
LListItem.GroupID := LListGroup.ID;
LListItem := lv.Items.Add;
LListItem.Caption := 'F150';
LListItem.GroupID := LListGroup.ID;
OutputDebugString(PChar(Format('lv.Groups.Count=%d', [lv.Groups.Count])));
end;
The first time you press a button, items appear and are grouped. The second time the list view is empty. If I comment on a line that clears groups, then it works, but the number of groups, all of which are not used, but one, increases each time.
source
share