0

UPDATE : My question is about FMX listView not about VCL one , that's to explaine that my Question isn't a duplicate of this question .

i'm trying to accomplish a kind of ListView Items hide mechanism by setting ListView.Item[x].Height:=0 , But that didn't give any result

Adding Items :

 procedure TForm6.AddItemsClick(Sender: TObject);
    var
    I:Integer;
    AItem: TListViewItem;
    begin
        for I := 0 to 5 do
         Begin
           AItem := ListView1.Items.Add;
           //with AItem do
               //   Text := 'Text';
         End;
    end;

Trying to hide Items :

 procedure TForm6.HideItemsClick(Sender: TObject);
    var
    I:Integer;
    begin
         ListView1.BeginUpdate;
         try
         for I := 0 to ListView1.ItemCount-1 do
         // ListView1.Items.Item[I].Height:=0; // doesn't give any result
          ListView1.Items.Item[I].Height:=1;
         finally
           ListView1.EndUpdate;
         end;

    end;

The Result

Any help to fix this please ? or why

ListView1.Items.Item[I].Height:=0;

Has no effect ?

Community
  • 1
  • 1
randydom
  • 395
  • 2
  • 20
  • Remove `ListView1.Items.Item[I].Height:=1;` – Ilyes Oct 22 '16 at 16:59
  • @Sami, if i remove that what will be the result ? – randydom Oct 22 '16 at 17:07
  • All items height = 0 . – Ilyes Oct 22 '16 at 17:08
  • @Sami , if you read my question : `ListView1.Items.Item[I].Height:=0;` will not give any result ( no effects ) – randydom Oct 22 '16 at 17:11
  • Hmmm if you need to hide all items , why you don't hide the list ? – Ilyes Oct 22 '16 at 17:22
  • @Sami , I don't want to hide the whole list but only some of its items . – randydom Oct 22 '16 at 17:25
  • 2
    It is hardcoded not to accept negative or zero height. The gray lines you see are separator lines. But I think you should consider not to keep your data in the control. Instead (speaking only about strings now) in e.g. a TStringList and signal the `ListView` to update itself when the content in the `StringList` is changed. – Tom Brunberg Oct 22 '16 at 17:32
  • 1
    Don't let a TListView become the container of your _actual_ data. Use the TListView as a _dumb_ data displayer. Hold your data in a non-ui class (ie list of something, array of something) and then have your TListView display only the elements you require – Agustin Ortu Oct 22 '16 at 18:48

0 Answers0