如何在图标模式下以列表视图显示图片?

问题描述 投票:-2回答:1

我使用Delphi Tokyo创建firemonkey应用程序,我需要显示如下图片:

enter image description here

有没有办法编辑TListView使它看起来像这样?

delphi firemonkey
1个回答
1
投票

我在VertScrollBox组件中使用TGridLayout做了类似的项目......

脚步...

  • 将VertScollBox放在表单中
  • 放置GridLayout(在vert滚动内)*有时滚动框不希望由于网格的宽度(或高度)而正确行为...我通常通过一个过程来调整它。
  • 添加一个按钮(vertScroll之外的任何地方)

添加项目的程序......

var
  pnl : TPanel;
begin
  pnl := TPanel.Create(self);
  pnl.text := 'hi there!';
  // here you should create and add images to panel. make sure the parent of each object is the pnl object.
  pnl.parent := GridLayout1;
end;

调整大小,添加时和删除项目时会调用以下代码。

procedure TfrmMain.adjustViews;
var
  itemsPerRows: double;
  rows: double;
begin
  // for grid on vertical scroll  
  if GridLayout1.ControlsCount > 0 then begin
    itemsPerRows :=  trunc(GridLayout1.Width / GridLayout1.ItemHeight);
    rows   := GridLayout1.ControlsCount / itemsPerRows;
    GridLayout1.height := rows * GridLayout1.ItemWidth;
  end;


  // for grid on horizontal scroll
  if GridLayout2.ControlsCount > 0 then
    GridLayout2.Width := GridLayout2.ControlsCount * GridLayout2.ItemWidth;
end;

笔记:

  • 这篇文章是直接输入的,所以你有一个想法,但不是我的代码本身!

希望能帮助到你!

© www.soinside.com 2019 - 2024. All rights reserved.