TableView: Missing Category

HEllo,

I have a problem with the Tableview. I I sometimes have categories which do not have an associated item but I would like to show them. However in Tableview those categories simply disappear.The following code shows this behaviour:

procedure TForm2.FormCreate(Sender: TObject);
var
  i: Integer;
begin
tv.Items.Clear;
tv.Categories.Clear;
tv.BeginUpdate;
for I := 0 to 4 do
  with tv.Categories.Add do
    begin
      Caption := 'Category ' + i.ToString();
      Id := i;
    end;
for I := 1 to 4 do
  with tv.Items.Add do
    begin
      Caption :='item ' + i.ToString();
      CategoryID := i;
    end;
tv.EndUpdate;
end;

Category 0 is not displayed. Is there any option to show this? Treeviews in Windows would show parent nodes without children. Or would you recommend a different approach?

Kind regards
Gernot

Hi, 


the Category is only displayed when there is an item available. empty categories are currently not available, but you can add an empty item with Visible := i > 0; in your second loop.

Kind Regards, 
Pieter

Many thanks - this helped

Kind regards
Gernot