如何更改FMX.TMemo字体大小@运行时?在下面的应用程序中,Spinbox1.Change方法不会更改Memo.Font.Size。我已经尝试过BeginUpdate()和EndUpdate()方法的TMemo。我也试过Memo1.Repant(),似乎什么都没有用。我查看了TMemo的每个属性、函数和过程,但是,我找不到我需要的东西。以后的Delphi版本有TTextSettings for TMemo,但是XE5没有。我还尝试了一个用于TMemo的类助手来添加一个TTextSettings属性,但是没有效果。
unit Unit13;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Graphics, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.StdCtrls,
FMX.Edit, FMX.Layouts, FMX.Memo;
type
TForm13 = class(TForm)
Memo1: TMemo;
ToolBar1: TToolBar;
SpinBox1: TSpinBox;
procedure FormCreate( Sender : TObject );
procedure SpinBox1Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form13: TForm13;
implementation
{$R *.fmx}
procedure TForm13.FormCreate( Sender : TObject );
begin
Memo1.Font.Size := SpinBox1.Value;
end;
procedure TForm13.SpinBox1Change(Sender: TObject);
begin
Memo1.Font.Size := SpinBox1.Value;
end;
end.使用FMX当然不像VCL。
发布于 2022-11-12 10:47:33
与许多其他控件一样,TMemo有一个属性StyledSettings,其中有几个子字段:Family、Size、Style、FontColor和Other。
默认情况下,除Other之外,所有控件都是True,因此控件将自动遵循任何已使用的style设置。在对象检查器中设置StyledSettings.Size = False,TMemo将遵循您自己的字体大小设置。

由于我没有任何比XE7更旧的XE版本,所以上面的内容都是用XE7测试的。如果XE5没有相应的设置,我将删除这个答案,因为它没有回答您的问题。
或者,您可以在代码中编写:
with Memo1 do
StyledSettings := StyledSettings - [TStyledSetting.ssSize];这在XE5中应该是可行的。
https://stackoverflow.com/questions/74412087
复制相似问题