Search code examples
delphidelphi-xe6

How to stop control resizing when removing anchoring?


When removing an anchoring, a control can automatically resize itself to some other size.

Steps to reproduce

  1. Drop a control on a form

    enter image description here

  2. Set an anchor

    enter image description here

  3. Resize the form; watch the control resize with it:

    enter image description here

  4. Remove the anchor:

    enter image description here

  5. Watch the control resize itself without permission:

    enter image description here


Solution

  • When you create control, It gets initial parameters. Among them there are height and width. When you enable anchoring and resize form, the control also resizes, but initial parameters don't change. Thats why, when you remove anchoring, it gets its initial size.