Reputation: 51
I'm trying to programmatically modify font sizes using the Fire Monkey library and nothing seems to work. Here is my latest attempt:
procedure TForm2.Button1Click(Sender: TObject);
var
i, j, k: integer;
w: single;
begin
k := 0;
with StringGrid1 do
begin
canvas.Font.Size := 24; //set font size
StringColumn2.visible := false; //hide this column
for i := 0 to columncount - 1 do //loop through columns
begin
columns[i].header := 'hdr' + inttostr(i + 1); //provide header content
w := StringGrid1.Canvas.TextWidth(columns[i].header); //measure width needed
for j := 0 to rowcount - 1 do //loop through rows
begin
k := k + 1; //variable cell content
if i = 0 then //do row label
cells[i, j] := 'Lyr' + inttostr(k)
else
begin //do row body
cells[i, j] := inttostr(k);
end;
w := max(w, StringGrid1.Canvas.TextWidth(cells[i, j])); //measure width needed
end;
columns[i].Width := w + 10; //set width
end;
end;
end;
end.
canvas.Font.Size := 24
has no effect on the font sizing, but there is an interesting side effect. Changing the font size changes the results provided by canvas.TextWidth
. So, there is a partial implementation of the font sizing. For those who would suggest font styles, none are in effect for this problem. In an earlier exercise, I encountered a similar lack of response to changes in font.size
for TEdit
components, but I don't know if font styles were in effect for that exercise; I know I didn't set any.
Upvotes: 3
Views: 1133
Reputation: 164
In the StringGrid1 properties you have StyledSettings. You must expand this property and set to False the Items you need to change.
In this case: Size.
Upvotes: 1