如何在FMX ListView中显示GlyphButton



在Delphi 10.4.2。这是个很简单的问题。一个新的多设备项目,将Listview添加到表单中。切换到设计模式,使用DynamicAppearance。添加2个文本项和1个glyphButton(复选框),连接数据源。

在设计时,没有复选框显示虽然Glyphbotton。可见是真的。在运行时,编写一个ListView1ItemClick,即使只有一行代码

AItem.Objects.GlyphButton.Visible:=true;

当点击一个项目时,会产生错误,如图所示。输入图片描述

知道当用户点击一个项目时如何显示复选框吗?这应该是一个非常简单的函数,为什么连谷歌都找不到答案呢?

示例代码位于github https://github.com/tanghzuk/ListView-Test

启用ToogleEditMode后,将ListViewItem ItemAppearance更改为Custom。

你可以显示和隐藏复选框:

procedure TForm1.ListView1ItemClick(const Sender: TObject; const AItem: TListViewItem);
begin
AItem.Objects.GlyphButton.Visible:= not AItem.Objects.GlyphButton.Visible;
end;

所有的信息都在docwiki: http://docwiki.embarcadero.com/RADStudio/Sydney/en/Customizing_FireMonkey_ListView_Appearance#Customizable_Item_Appearances

最新更新