下面是我的“自定义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