【问题标题】:How to enable or disable an item in aTListView with dynamic appearance?如何启用或禁用具有动态外观的 aTListView 中的项目?
【发布时间】:2021-04-14 03:14:24
【问题描述】:

我有一个具有动态外观的 TListView,其中有一些项目,如文本和图像。我想在运行时根据情况禁用或启用这些项目。

直到那一刻,我才在互联网上找到参考资料。感谢您的帮助..

例如:

ListView.Items.Clear;
x:=0
while not Query.eof do
begin
  Item := ListView.Items.Add;

  Listview.Items.AppearanceItem[x].Data['IdItem'] := x;
  Listview.Items.AppearanceItem[x].Data['Status'] := vStatus;
  if vStatus = 1 then   
     Listview.Items.ApperanceItm[x]....:= "enabled or disable";
  Query.next;
  x:=x+1;
end;

【问题讨论】:

标签: listview delphi firemonkey delphi-10.3-rio


【解决方案1】:

我认为您的意思是这些项目是否可见,取决于条件。

您必须使用以下代码在 OnUpdateObjects 事件处理程序中应用这些更改,例如:

procedure TForm1.ListViewUpdateObjects(const Sender: TObject;const AItem: TListViewItem);
var txt : TListItemText;
    img : TListItemImage;
begin
  txt := TListItemText(Aitem.Objects.FindDrawable('Status'));
  if txt.Text='1' then
  begin
    img := TListItemImage(AItem.Objects.FindDrawable('ImageStatus')); // ImageStatus is the name of the TImageObjectAppearance you want to show or hide
    img.Visible := false;
    txt.Visible := false;
  end;
end;

【讨论】:

  • @Roberto Zambrano 已经按照您的预期解决了这个问题?
猜你喜欢
  • 2023-03-18
  • 2015-02-23
  • 1970-01-01
  • 1970-01-01
  • 2014-03-02
  • 2017-04-23
  • 1970-01-01
  • 2017-08-28
  • 1970-01-01
相关资源
最近更新 更多