如何改变文本框中文本的对齐方式

z391723 2003-07-24 04:36:55
请教如何让文本框Edit中的文字右对齐或是居中对齐呢?谢谢
...全文
87 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoxiao197821 2003-07-24
  • 打赏
  • 举报
回复
{重载AEdit使其右对齐}
procedure TAEdit.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
Params.Style:=Params.Style or ES_RIGHT;
end; //同理可居中
firetoucher 2003-07-24
  • 打赏
  • 举报
回复
设置后,刷新一下
Edit1.Refresh ;
firetoucher 2003-07-24
  • 打赏
  • 举报
回复
SetWindowLong(Edit1.handle, GWL_STYLE,GetWindowlong(edit1.Handle, GWL_STYLE) +ES_CENTER);
SetWindowLong(Edit1.handle, GWL_STYLE,GetWindowlong(edit1.Handle, GWL_STYLE) +ES_RIGHT);
  • 打赏
  • 举报
回复
delphi的edit不支持

继承TEdit,重载CreateParams,修改Param即可。
procedure TEdit_Ex.CreateParams(var Params: TCreateParams);
begin
inherited;
if self.FTextOnRight then Params.Style:=Params.Style or ES_RIGHT;
end;

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧