gpt4 book ai didi

delphi - 无法在 Delphi 中更改 TEdit 高度

转载 作者:行者123 更新时间:2023-12-05 07:31:25 27 4
gpt4 key购买 nike

下面是我的自定义 TEdit 控件的示例代码。

type
TEdit = class(Vcl.StdCtrls.TEdit)
private
//FTextM : TEXTMETRIC;
public
constructor Create(AOwner : TComponent); override;
end;

constructor TEdit.Create(AOwner: TComponent);
begin

inherited Create(AOwner);
BorderStyle := bsNone;
Text := '';

Font.Name := 'Segoe UI';
Font.Size := 9;


Height := 10; //Here height change is not reflected.
end;

在这里,无论我在 Height 中给出什么值,它都不会在运行时更新。我严重错过了非常简单的事情。但我无法自己弄清楚。

什么是更新 tedit 控件高度的正确方法。

更新:这是我正在使用的表单代码。

object Form2: TForm2
Left = 0
Top = 0
Caption = 'Form2'
ClientHeight = 242
ClientWidth = 472
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Edit2: TEdit
Left = 216
Top = 184
Width = 121
Height = 21
TabOrder = 1
Text = 'Edit2'
end
object Edit3: TEdit
Left = 40
Top = 136
Width = 121
Height = 21
TabOrder = 0
Text = 'Edit3'
end
end

最佳答案

要能够更改 TEdit 的 Height 属性,您必须首先将 Autosize 属性设置为 False。否则,在运行时控件将根据字体大小更改其高度。

关于delphi - 无法在 Delphi 中更改 TEdit 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51810424/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com