'Access FMX TListView TListViewItem
Is there a way to access the different items configured to a FMX TListview's ListViewItem component below the ListView rows are filled?
I have a TListView set to DynamicAppearance and have it set up as shown in the image below.
Based on a field in a database, I need to make some of the Items under columns 1 to 9 invisible. I have been able to make this work using the code below within the UpdateObjects event, but was wondering if there is any way I can accomplish the same thing when the database is open, instead of when each ListViewItem is updated.
procedure TfrmHistoryRuntime.ListView1UpdateObjects(const Sender: TObject; const AItem: TListViewItem);
begin
Drawable := TListItemText(AItem.View.FindDrawable('DateTime'));
if assigned(Drawable) then
Drawable.Height := 52;
AItem.Height := 54;
for I := 1 to 9 do
begin
Drawable := TListItemText(AItem.View.FindDrawable('Device' + IntToStr(I)));
if assigned(Drawable) then
Drawable.Visible := IsBitSet(fGroups, I);
Drawable := TListItemText(AItem.View.FindDrawable('Real' + IntToStr(I)));
if assigned(Drawable) then
Drawable.Visible := IsBitSet(fGroups, I);
end;
end;
I did figure out I can access the items using code similar to below, but don't know if there is a way to set the index value using the Item name and not a number (which might change)?
ListView1.ItemAppearanceObjects.ItemObjects.Objects[0].Height := 52;
ListView1.ItemAppearance.ItemHeight := 54;
ListView1.ItemAppearanceObjects.ItemObjects.Objects[2].Visible := false;
ListView1.ItemAppearanceObjects.ItemObjects.Objects[12].Visible := false;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|