0
Fill Stringgrid row with variable of N characters
Greetings to all
I am using this code only to play the letters without values in stringgrid
procedure TForm1.Button1Click(Sender: TObject); var t: TStringList; i:integer; begin t := TStringList.create; // cria uma classe t.text := stringReplace(Edit1.Text, '|', #13,[rfReplaceAll]);//substitui | por quebra de linha for i := 0 to Pred(t.Count) do StringGrid1.cells[i+1,2]:=t[i]; // joga todos elementos do edit na stringgrid //i+1 para prencher a partir da coluna 2 t.free; // destruir a classe end;
it would be possible to play an unknown variable number of characters in only one Stringgrid row, knowing that each character has a value, which corresponds to the amount of columns it will occupy, using Tstringlist?
xdyz the variable string is composed N characters
1342 ( each character of the string has a value and each of them corresponds to a number of columns )
for:
character x = 1 cells [ x ]
character d = 3 cells [ d ] [ d ][ d ]
y character = 4 cells [ y] [ y ][ y ][ y ]
z character = 2 cells [ z] [ z ]
............
final result on a single Stringgrid line for this 4-character variable
[ x ][ d ][ d ][ d ][ y] [ y ][ y ][ y ][ z] [ z ] .........
The most simple would create a
matriz
of 2 columns, storing the character and its value, and to fill theStringGrid
, go through the string and check each character in the matrix, after finding the character, fill in theStringGrid
x times depending on the value found, and pass to next.– Pedro Roweder
hello Pedro Roweder, I could give an example, because I need to play the information to stay in a single stringgrid line
– user101552