如何让edit里的文字居中? 如何让edit里的文字居中? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Edit1.Alignment := taCenter; unit MyEdit;interfaceuses Controls,Windows, Messages, SysUtils, Variants, Classes, Graphics,Forms, Dialogs, StdCtrls;type TMyEdit=class(TEdit) private FAlignment:TAlignment; procedure SetAlignment(const Value: TAlignment); procedure CreateParams(var Params:TCreateParams);override; protected published property Alignment:TAlignment read FAlignment write SetAlignment; end;implementation{ TMyEdit }constructor TMyEdit.Create(AOwner: TComponent);begin inherited;end;procedure TMyEdit.CreateParams(var Params: TCreateParams);begin inherited; case FAlignment of taLeftJustify: begin Params.Style := Params.Style + ES_LEFT; end; taRightJustify: begin Params.Style := Params.Style + ES_RIGHT; end; taCenter: begin Params.Style := Params.Style + ES_CENTER; end; end;end;procedure TMyEdit.SetAlignment(const Value: TAlignment);begin if FAlignment<>Value then begin FAlignment := Value; RecreateWnd; end;end;end.---------------uses MyEdit;procedure TForm1.Button1Click(Sender: TObject);var MyEdit:TMyEdit;begin MyEdit:=TMyEdit.Create(Form1); MyEdit.Alignment:=taCenter; MyEdit.Parent:=Form1;end; 重载有些过了,呵呵,Edit1.Alignment := taCenter;这个方便。祝:身体健康! 谁能给我一个TreeView响应单击某一节点小例子!谢谢! StringGrid如何使一行变成粗体? 我想问下About属性怎么做啊 TreeView怎样加图标! 动态生成一个query 出错请高手指教! 怎么把字符串‘12.3’转换为数字!再乘以100 得出1230这样的? 怎样在运行过程中判断窗体已经建立并显示? 求大家一个问题.我已经快疯了?我在等待ing 关于焦点的问题? 接口 关于dbgrid的简单问题 关于delphi的串口通信问题,不是用mscomm或者spcomm,用modem直接,建议大家进来侃侃,对做商品化的软件有帮助的
Controls,Windows, Messages, SysUtils, Variants, Classes, Graphics,Forms, Dialogs, StdCtrls;
type
TMyEdit=class(TEdit)
private
FAlignment:TAlignment;
procedure SetAlignment(const Value: TAlignment);
procedure CreateParams(var Params:TCreateParams);override;
protected
published
property Alignment:TAlignment read FAlignment write SetAlignment;
end;
implementation{ TMyEdit }constructor TMyEdit.Create(AOwner: TComponent);
begin
inherited;end;procedure TMyEdit.CreateParams(var Params: TCreateParams);
begin
inherited;
case FAlignment of
taLeftJustify:
begin
Params.Style := Params.Style + ES_LEFT;
end;
taRightJustify:
begin
Params.Style := Params.Style + ES_RIGHT;
end;
taCenter:
begin
Params.Style := Params.Style + ES_CENTER;
end;
end;
end;
procedure TMyEdit.SetAlignment(const Value: TAlignment);
begin
if FAlignment<>Value then
begin
FAlignment := Value;
RecreateWnd;
end;
end;
end.---------------
uses MyEdit;procedure TForm1.Button1Click(Sender: TObject);
var
MyEdit:TMyEdit;
begin
MyEdit:=TMyEdit.Create(Form1);
MyEdit.Alignment:=taCenter;
MyEdit.Parent:=Form1;
end;
这个方便。祝:身体健康!