Rio中使用ListBox嵌入Frame实现卡片式效果

本文介绍了一种使用Delphi中的ListBox与自定义Frame组件创建复杂用户界面的方法。通过循环创建并填充多个Frame,实现了动态加载内容的效果,每个Frame包含多种控件,如矩形、标签、圆形、线条和速度按钮,展示了如何在ListBox中加载这些Frame。

问题:看到如图效果,如何实现。

 

思路:使用ListBox加入Frame来实现,ListBox为容器显示重复记录,Frame作为单个内容展现的组件。

1、新建Frame单元。

2、在新建的Frame窗体上放置相应得组件:rectangle+label+circle+line+speedbutton等。如图。

 

 

3、在主要界面上放置一个ListBox组件。

4、编写addlistframe函数,目的:加载Frame到ListBox中。

   procedure SpeedButton2Click(Sender: TObject);
     procedure addlistframe();
  private
    { Private declarations }
    itemlist: array[0..99] of TListBoxItem;
var
  Form7: TForm7;

implementation

uses
  unit9;

var
  i: integer;
const
  NamePrefix = 'panel';
begin
  begin
    for i := 0 to 30 do
    begin
      tFrame9(FindComponent(NamePrefix + IntToStr(i))).DisposeOf;
      itemlist[i].DisposeOf;
    end;
    Lista.Clear;

    for i := 0 to 30 do
    begin
      itemlist[i] := TListBoxItem.Create(self);
      itemlist[i].Parent := Lista;
      itemlist[i].Selectable := False;
      itemlist[i].Height:=200;
      itemlist[i].Margins.Top:=10;
      itemlist[i].Margins.Bottom:=10;
      itemlist[i].Margins.Left:=20;
      TFrame9.Create(self).Name := NamePrefix + IntToStr(i);
      with tFrame9(FindComponent(NamePrefix + IntToStr(i))) do
      begin
        Parent := itemlist[i];
        label2.text:='客户'+inttostr(i);
        label3.text:=datetostr(date+i);
        label4.text:='地址'+inttostr(i);
        label5.text:=inttostr(i)+'待出库';
        text1.text:='进行中';

      end;
    end;
  end;

 

5、调用以上函数。

procedure TForm7.SpeedButton2Click(Sender: TObject);
begin
  addlistframe();
end;

结果。

 

 

 

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值