本文介绍了Firemonkey TEdit高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Delphi Seattle,而我的应用程序是针对Windows桌面的.

I'm using Delphi Seattle and my application is for Windows Desktop.

我正在尝试更改TEdit的字体大小.因此,高度也被修改.在设计时一切正常,但是当我运行我的应用程序时,TEdit会忽略高度修改并剪切文本.

I'm trying to change the font size of a TEdit. Consequently the height was also modified. At design time everything works well, but when I run my application TEdit ignores the height modification and the text is cut.

我已尝试根据建议,但我找不到此属性.

I've tried to find FixedHeight as suggested here, but I couldn't find this property.

是否可以更改TEdit Heigth?

Is it possible to change TEdit Heigth?

推荐答案

这可以通过覆盖控件的 AdjustFixedSize 方法来解决.如@chrisrolliston所述,删除FMX控件的大小限制,并举例说明了这里:

This can be solved by overriding the control’s AdjustFixedSize method.As explained by @chrisrolliston, Removing a FMX control’s size restrictions and exemplified here:

unit Unit4;
interface
uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Edit, MyTEdit;

type
  TForm4 = class(TForm)
    Edit1: TEdit;
    procedure FormCreate(Sender: TObject);
  end;

var
  Form4: TForm4;

implementation

{$R *.fmx}

procedure TForm4.FormCreate(Sender: TObject);
begin
  Edit1.Height := 60;
end;

end.


unit MyTEdit;
interface
uses
  FMX.Edit, FMX.Controls;

type
  TEdit = class(FMX.Edit.TEdit)
  protected
    procedure AdjustFixedSize(const Ref: TControl); override;
  end;

implementation
uses
  FMX.Types;

procedure TEdit.AdjustFixedSize(const Ref: TControl);
begin
  SetAdjustType(TAdjustType.None);
end;

end.

这篇关于Firemonkey TEdit高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-11 07:44