问题
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