锚点:= [akCenter]? [英] Anchors := [akCenter]?

查看:181
本文介绍了锚点:= [akCenter]?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将控件置于其父项中?当父母调整大小时,如何保持居中?

How can I center a control within its parent? And how to keep it centered when the parent resizes?

我知道我可以写一个 Parent.OnResize 事件处理程序手动移动控件,但不是所有的容器组件都有一个 OnResize 事件,我想自动执行。

I know I could write a Parent.OnResize event handler to move the control manually, but not all container components have an OnResize event, and I would like to do this automatically.

有没有一个 akCenter 锚?

推荐答案

code> akCenter 不存在。但是,通过将anchors属性设置为空,可以模仿 akRelative ,导致当父级调整大小时控件的相对移动。结合中心位置将导致与中心相似的锚。

The anchor akCenter does not exist. But you can mimic akRelative by setting the anchors property empty which results in relative movement of the control when the parent resizes. Combining that with centered placement will result in a centered-alike "anchor".

在设计时水平居中:


  • 在IDE中,选择控件的上下文菜单(右键单击),

  • 位置>对齐>水平>窗口中的中心

  • 设置 Anchors.akLeft:= False Anchors.akRight:= False 在对象检查器中,

  • Etvoilà: akHorzCenter

  • In the IDE, choose the context menu of the control (right click),
  • Position > Align > Horizontal > Center in Window,
  • Set Anchors.akLeft := False, Anchors.akRight := False in the object inspector,
  • Et voilà : akHorzCenter.

垂直相同,在这种情况下您设置 akTop akBottom 假。要沿两个方向居中: Anchors:= []

The same goes for vertical, in which case you set akTop and akBottom false. To center in both directions: Anchors := [].

免责声明:我没有找到这个锚的用法的文档,我做不知道这是否是预期的功能,但它在D7以及XE2中非常好。

Disclaimer: I have not found documentation of this anchors usage and I do not know whether this is the intended functioning, but it works very nice in D7 as well as in XE2.

这篇关于锚点:= [akCenter]?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆