How to set button's anchor property dynamically?

 ̄綄美尐妖づ 提交于 2020-01-03 17:21:27

问题


I want to set TBitBtn's anchor property dynamically.

First I have set the button's anchor as top right in design time. In that button click event I set form's BorderStyle as bsDialog. Then there should be a gap as shown in image. I want the button should be beside close button.

So I need to set button's left and its anchor as top right after assigning border style as bsDialog. Is it correct?

I don't know the way to change anchor property dynamically

Thanks, Rakesh


回答1:


I don't know if I can see your problem. If it's about syntax then here you go:

  BitBtn1.Left:= 666;
  BitBtn1.Anchors := [akTop, akRight];

This is the way to modify position and anchor in code.




回答2:


In Delphi FireMonkey (XE4) to set anchors dynamically you do:

Button1.Anchors := [TAnchorKind.akTop, TAnchorKind.akRight];


来源:https://stackoverflow.com/questions/7832880/how-to-set-buttons-anchor-property-dynamically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!