Tony Taylor
Tony Taylor

Reputation: 59

How to fill TStringGrid in Delphi FireMonkey?

I am trying to create a multi-device application in Delphi. I have placed my TStringGrid on form. Increased column count to 4. I have a stringlist List3 with 4 elements. List3 does contain data.

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

No data shows up in StringGrid1. neither hard coded for row 0 or dynamically using for loop.

Upvotes: 2

Views: 2637

Answers (2)

Tony Taylor
Tony Taylor

Reputation: 59

The Tstringgrid was not filling because I was in usb debug mode. Once I disconnected from computer and executed the apk the grid filled correctly.

Upvotes: 1

Abdullah Ilgaz
Abdullah Ilgaz

Reputation: 739

Did you try to refresh or clicking some visual components in your form?

FMX needed some action to reload your data. The easiest way to determine this, just try to use BeginUpdate and EndUpdate functions in it.

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;

Upvotes: 0

Related Questions