Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set button's anchor property dynamically?

Tags:

delphi

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 enter image description here

Thanks, Rakesh

like image 630
Rakesh Devarasetti Avatar asked Dec 07 '22 18:12

Rakesh Devarasetti


2 Answers

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

Button1.Anchors := [TAnchorKind.akTop, TAnchorKind.akRight];
like image 149
Edijs Kolesnikovičs Avatar answered Dec 18 '22 02:12

Edijs Kolesnikovičs


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.

like image 45
Heinrich Ulbricht Avatar answered Dec 18 '22 03:12

Heinrich Ulbricht