如何在Delphi FireMonkey中填充TStringGrid?

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

我正在尝试在Delphi中创建一个多设备应用程序。我已将TStringGrid放在表单上。将列数增加到4.我有一个包含4个元素的stringlist List3。 List3确实包含数据。

StringGrid1.Cells[0,0] := 'adc';
StringGrid1.cells[1,0] := 'efg';
StringGrid1.Cells[2,0] := 'hij';

for n1 := 1 to p2-1 do
begin
    StringGrid1.Cells[3,n1] := Trim(List3[0]);
    StringGrid1.cells[0,n1] := Trim(List3[1]);
    StringGrid1.Cells[1,n1] := Trim(List3[2]);
    StringGrid1.Cells[2,n1] := Trim(List3[3]);
end

StringGrid1中没有数据显示。既没有硬编码为第0行,也没有动态使用for循环。

android delphi firemonkey
2个回答
1
投票

由于我处于USB调试模式,因此Tstringgrid没有填充。一旦我从计算机断开连接并执行apk,网格就会正确填充。


0
投票

您是否尝试刷新或单击表单中的某些可视组件?

FMX需要一些操作来重新加载您的数据。确定这一点的最简单方法,只是尝试在其中使用BeginUpdate和EndUpdate函数。

StringGrid1.BeginUpdate; 

for n1 := 1 to p2-1 do
begin
 StringGrid1.Cells[3,n1] := Trim(List3[0]);
 StringGrid1.cells[0,n1] := Trim(List3[1]);
 StringGrid1.Cells[1,n1] := Trim(List3[2]);
 StringGrid1.Cells[2,n1] := Trim(List3[3]);
end;

StringGrid1.EndUpdate;
© www.soinside.com 2019 - 2024. All rights reserved.