访问 TListBox 项目中的 TFrame 对象

问题描述 投票:0回答:1

我有一个带有

TFrame
字段的
TNumberBox
,该字段在 Firemonkey 中的
TListBox
内多次插入。循环遍历
TListBox.ListItems
时如何访问该对象的值?

框架:

type
  TfrmTipoOrc = class(TFrame)
    Rectangle1: TRectangle;
    edValor: TNumberBox;
  end;

形式:

type
  TfrmOrcamento = class(TForm)
    btnSalvar: TSpeedButton;
    listaOrcamento: TListBox;
    procedure btnSalvarClick(Sender: TObject);
  end;

implementation

procedure TfrmOrcamento.btnSalvarClick(Sender: TObject);
var
    i: integer; 
    vValor: Double;
begin    
    for i := 0 to Pred(listaOrcamento.Count) do
        begin
            // vValor := vValor + edValor.Value;
            // How to access the **edValor** object (in the Frame)?
        end;
end;
delphi listbox firemonkey tlistbox
1个回答
1
投票
procedure TfrmOrcamento.btnSalvarClick(Sender: TObject);
var
    i : integer; 
    vValor : Double;
begin    
    for i := 0 to Pred(listaOrcamento.Count) do
        begin
              vValor:=vValor+
              TfrmTipoOrc(listaOrcamento.ListItems[i].Components[0]).edValor.Value;
        end;
end;
© www.soinside.com 2019 - 2024. All rights reserved.